当前位置: 首页>>代码示例>>Java>>正文


Java RunNotifier.fireTestRunFinished方法代码示例

本文整理汇总了Java中org.junit.runner.notification.RunNotifier.fireTestRunFinished方法的典型用法代码示例。如果您正苦于以下问题:Java RunNotifier.fireTestRunFinished方法的具体用法?Java RunNotifier.fireTestRunFinished怎么用?Java RunNotifier.fireTestRunFinished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.runner.notification.RunNotifier的用法示例。


在下文中一共展示了RunNotifier.fireTestRunFinished方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:55,代码来源:XpectConfigurationDelegate.java

示例2: run

import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
public void run() {
    RTestDynamicClassLoader classLoader;
    final AtomicBoolean shouldRun = new AtomicBoolean(true);
    ServerSideInternalRemoteRunner runner = null;
    while(shouldRun.get()) {
        RTestData rTestData = remoteInvoker.read();
        if(rTestData instanceof CreateRunnerData) {
            CreateRunnerData data = (CreateRunnerData)rTestData;
            // instantiate the class loader
            classLoader = new RTestDynamicClassLoader(
                    getClass().getClassLoader(),
                    remoteInvoker, data.getId(), data.getRemoteResourcesToAskFromClient());
            String classNameToLoad = data.getClassName();

            runner = new ServerSideInternalRemoteRunner(classLoader);
            runner.init(classNameToLoad);
            remoteInvoker.send(new RunnerDataCreated(data.getId(), data.getClassName()));

        }
        else if(rTestData instanceof GetDescriptionData) {
            if(runner != null) {
                GetDescriptionData getDescriptionData = (GetDescriptionData) rTestData;
                Description description = runner.getDescription();
                remoteInvoker.send(new GotDescriptionData(getDescriptionData.getId(), description));
            }
        }
        else if(rTestData instanceof FilterData) {
            FilterData filterData = (FilterData) rTestData;
            if(runner != null) {
                try {
                    runner.filter(filterData.getFilter());
                } catch (NoTestsRemainException e) {
                    e.printStackTrace();
                }
            }
        }
        else if(rTestData instanceof SortData) {
            SortData sortedData = (SortData) rTestData;
            if(runner != null) {
               runner.sort(sortedData.getSorter());
            }
        }
        else if(rTestData instanceof StartRunningData) {
            if(runner != null) {
                StartRunningData startRunningData = (StartRunningData) rTestData;
                RunNotifier runNotifier = new RunNotifier();
                runNotifier.addListener(new RemoteRunNotificationListener(remoteInvoker, startRunningData.getId()));

                Result result = new Result();
                RunListener listener= result.createListener();
                runNotifier.addFirstListener(listener);
                runNotifier.fireTestRunStarted(runner.getDescription());
                runner.run(runNotifier);
                runNotifier.fireTestRunFinished(result);
            }
        }
        else if(rTestData instanceof AskForReportData) {
            // read generated report and send the report back
            AskForReportData askForReportData = (AskForReportData) rTestData;
            byte [] reportBytes = reportProcessor.readReport(askForReportData.getClassName());
            TestReportGeneratedData reportGeneratedData = new TestReportGeneratedData(askForReportData.getId(), askForReportData.getClassName(), reportBytes);
            remoteInvoker.send(reportGeneratedData);
        }
        else if(rTestData instanceof EndProtocolData) {
            shouldRun.set( false );
        }
    }
    remoteInvoker.close();




}
 
开发者ID:MarkBramnik,项目名称:rtest,代码行数:75,代码来源:ServerTestProcessor.java


注:本文中的org.junit.runner.notification.RunNotifier.fireTestRunFinished方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。