當前位置: 首頁>>代碼示例>>Java>>正文


Java RunNotifier.addFirstListener方法代碼示例

本文整理匯總了Java中org.junit.runner.notification.RunNotifier.addFirstListener方法的典型用法代碼示例。如果您正苦於以下問題:Java RunNotifier.addFirstListener方法的具體用法?Java RunNotifier.addFirstListener怎麽用?Java RunNotifier.addFirstListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.junit.runner.notification.RunNotifier的用法示例。


在下文中一共展示了RunNotifier.addFirstListener方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: takeScreenShot

import org.junit.runner.notification.RunNotifier; //導入方法依賴的package包/類
/**
 * Méthode takeScreenShot.
 * @throws SaladiumException
 */
public String takeScreenShot() {
    String pathScreenShot = "";
    try {
        String capturePath = AbstractWorker.capturePath;
        File scrFile = ((TakesScreenshot) this).getScreenshotAs(OutputType.FILE);
        FileUtil.upload(scrFile.getAbsolutePath(), capturePath + "/" + scrFile.getName());
        pathScreenShot = capturePath + "/" + scrFile.getName();
        this.logger.info("ScreenShot effectué" + pathScreenShot);
    } catch (Exception e1) {
        this.logger.info("takeScreenShot échoué");
        e1.printStackTrace();
    }
    // try {
    // // déconnexion
    // By decoLocator = By.cssSelector("#logoff > a");
    // WebElement webElement = wait.until(ExpectedConditions.elementToBeClickable(decoLocator));
    // webElement.click();
    // } catch (TimeoutException e) {
    // Assert.fail("Tentative de forçage de déconnexion après un sreenshot échouée");
    // }
    // A activer si vous souhaitez arrêter les tests dès le premier screenshot effectué (idéal en mode dev ou debug)
    RunNotifier notifier = new RunNotifier();
    Result result = new Result();
    RunListener listener = result.createListener();
    notifier.addFirstListener(listener);
    notifier.pleaseStop();
    return pathScreenShot;
}
 
開發者ID:Nonorc,項目名稱:saladium,代碼行數:33,代碼來源:SaladiumDriver.java

示例2: runChild

import org.junit.runner.notification.RunNotifier; //導入方法依賴的package包/類
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
    try {
        resolveFailureCollectorRule(method);
        notifier.addFirstListener(new FailureListener(failureCollector));
    } catch (Exception e) {
        notifier.fireTestFailure(new Failure(createTestDescription(method.getDeclaringClass(), method.getName()), e));
    }
    super.runChild(method, notifier);
}
 
開發者ID:aalmiray,項目名稱:javatrove,代碼行數:11,代碼來源:FunctionalTestRunner.java

示例3: 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

示例4: run

import org.junit.runner.notification.RunNotifier; //導入方法依賴的package包/類
@Override
public void run(RunNotifier notifier) {
	notifier.addFirstListener(listener);
	super.run(notifier);
	notifier.removeListener(listener);
}
 
開發者ID:Devexperts,項目名稱:QD,代碼行數:7,代碼來源:TraceRunnerWithParameters.java

示例5: 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.addFirstListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。