本文整理汇总了Java中org.junit.runner.Result.createListener方法的典型用法代码示例。如果您正苦于以下问题:Java Result.createListener方法的具体用法?Java Result.createListener怎么用?Java Result.createListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.runner.Result
的用法示例。
在下文中一共展示了Result.createListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.junit.runner.Result; //导入方法依赖的package包/类
/**
* Do not use. Testing purposes only.
*/
public Result run(org.junit.runner.Runner runner) {
Result result = new Result();
RunListener listener = result.createListener();
notifier.addFirstListener(listener);
try {
notifier.fireTestRunStarted(runner.getDescription());
runner.run(notifier);
notifier.fireTestRunFinished(result);
} finally {
removeListener(listener);
}
return result;
}
示例2: takeScreenShot
import org.junit.runner.Result; //导入方法依赖的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;
}
示例3: execute
import org.junit.runner.Result; //导入方法依赖的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();
}