Java Code Examples for org.junit.runner.notification.RunNotifier#fireTestRunStarted()

The following examples show how to use org.junit.runner.notification.RunNotifier#fireTestRunStarted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRunner.java    From spoon-examples with GNU General Public License v2.0 5 votes vote down vote up
public static List<Failure> runTest(String fullQualifiedName, String testCaseName, String[] classpath) throws MalformedURLException, ClassNotFoundException {
    ClassLoader classLoader = new URLClassLoader(
            arrayStringToArrayUrl.apply(classpath),
            ClassLoader.getSystemClassLoader()
    );
    Request request = Request.method(classLoader.loadClass(fullQualifiedName), testCaseName);
    Runner runner = request.getRunner();
    RunNotifier fNotifier = new RunNotifier();
    final TestListener listener = new TestListener();
    fNotifier.addFirstListener(listener);
    fNotifier.fireTestRunStarted(runner.getDescription());
    runner.run(fNotifier);
    return listener.getTestFails();
}
 
Example 2
Source File: TestRunner.java    From spoon-examples with GNU General Public License v2.0 5 votes vote down vote up
public static List<Failure> runTest(String fullQualifiedName, String[] classpath) throws MalformedURLException, ClassNotFoundException {
    ClassLoader classLoader = new URLClassLoader(
            arrayStringToArrayUrl.apply(classpath),
            ClassLoader.getSystemClassLoader()
    );
    Request request = Request.classes(classLoader.loadClass(fullQualifiedName));
    Runner runner = request.getRunner();
    RunNotifier fNotifier = new RunNotifier();
    final TestListener listener = new TestListener();
    fNotifier.addFirstListener(listener);
    fNotifier.fireTestRunStarted(runner.getDescription());
    runner.run(fNotifier);
    return listener.getTestFails();
}
 
Example 3
Source File: XpectConfigurationDelegate.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Runs provided File in Engine. Returns output of execution.
 */
public void execute(ILaunch launch, XpectRunConfiguration runConfiguration) throws RuntimeException {

	Job job = new Job(launch.getLaunchConfiguration().getName()) {

		@Override
		protected IStatus run(IProgressMonitor monitor) {
			XpectRunner xr;
			try {
				xr = new XpectRunner(N4IDEXpectTestClass.class);
			} catch (InitializationError e) {
				N4IDEXpectUIPlugin.logError("cannot initialize xpect runner", e);
				return Status.CANCEL_STATUS;
			}

			// TODO support multiple selection
			/*
			 * if Project provided, or package files should be discovered there. Also multiple selected files
			 */
			String testFileLocation = runConfiguration.getXtFileToRun();

			IXpectURIProvider uriprov = xr.getUriProvider();
			if (uriprov instanceof N4IDEXpectTestURIProvider) {
				((N4IDEXpectTestURIProvider) uriprov).addTestFileLocation(testFileLocation);
			}

			Result result = new Result();
			RunNotifier notifier = new RunNotifier();
			RunListener listener = result.createListener();
			N4IDEXpectRunListener n4Listener = new N4IDEXpectRunListener();

			notifier.addFirstListener(listener);
			notifier.addListener(n4Listener);

			try {
				notifier.fireTestRunStarted(xr.getDescription());
				xr.run(notifier);
				notifier.fireTestRunFinished(result);
			} finally {
				notifier.removeListener(n4Listener);
				notifier.removeListener(listener);
			}
			// Do something with test run result?
			// return result;

			return Status.OK_STATUS;
		}

	};
	job.setUser(true);
	job.schedule();
}
 
Example 4
Source File: D2JunitRunner.java    From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override public void run(RunNotifier notifier){
    notifier.addListener(new D2JunitTestListener());
    notifier.fireTestRunStarted(getDescription());
    super.run(notifier);
}