本文整理汇总了Java中org.junit.platform.launcher.core.LauncherFactory类的典型用法代码示例。如果您正苦于以下问题:Java LauncherFactory类的具体用法?Java LauncherFactory怎么用?Java LauncherFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LauncherFactory类属于org.junit.platform.launcher.core包,在下文中一共展示了LauncherFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
@SuppressWarnings("unused")
public static void main(String[] args) {
// Discover and filter tests
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder
.request()
.selectors(selectPackage("io.github.bonigarcia"),
selectClass(DummyTest.class))
.filters(includeClassNamePatterns(".*Test")).build();
Launcher launcher = LauncherFactory.create();
TestPlan plan = launcher.discover(request);
// Executing tests
TestExecutionListener listener = new SummaryGeneratingListener();
launcher.registerTestExecutionListeners(listener);
launcher.execute(request, listener);
}
开发者ID:PacktPublishing,项目名称:Mastering-Software-Testing-with-JUnit-5,代码行数:19,代码来源:LauncherApiExample.java
示例2: main
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
try (SocketChannel channel = openSocket()) {
TestExecutionListener listener = createListener(channel);
Launcher launcher = LauncherFactory.create();
launcher.registerTestExecutionListeners(listener);
ObjectInputStream inputStream = openInput();
Map<String, List<String>> config = (Map<String, List<String>>) inputStream.readObject();
Set<File> roots = config.get("classpathRoots").stream()
.map(File::new)
.collect(Collectors.toSet());
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(selectClasspathRoots(roots))
.build();
launcher.execute(request);
}
}
示例3: runClasses
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
private void runClasses(Class<?>... classes) {
final ClassSelector[] classSelectors = Stream.of(classes)
.map(DiscoverySelectors::selectClass)
.toArray(ClassSelector[]::new);
final LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(classSelectors)
.build();
AllureJunit5AnnotationProcessor.setLifecycle(lifecycle);
final Launcher launcher = LauncherFactory.create();
launcher.execute(request, new AllureJunit5(lifecycle));
}
示例4: runClasses
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
private void runClasses(Class<?>... classes) {
final ClassSelector[] classSelectors = Stream.of(classes)
.map(DiscoverySelectors::selectClass)
.toArray(ClassSelector[]::new);
final LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(classSelectors)
.build();
final Launcher launcher = LauncherFactory.create();
launcher.execute(request, new AllureJunit5(lifecycle));
}
示例5: runTests
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
public static TestPlanExecutionReport runTests(Class<?> clazz) {
Launcher launcher = LauncherFactory.create();
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(selectClass(clazz))
.build();
ExecutionReportListener listener = new ExecutionReportListener().addClassToSkip(clazz);
launcher.execute(request, listener);
return listener.getReport();
}
示例6: execute
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
public ExitStatus execute(SummaryGeneratingListener listener,
DiscoverySelector selector,
ApplicationConfiguration applicationConfiguration,
FilesLocator filesLocator) {
ApplicationConfigurationResolver.setConfiguration(applicationConfiguration);
FilesLocatorResolver.setFilesLocator(filesLocator);
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(selector)
.build();
Launcher launcher = LauncherFactory.create();
launcher.registerTestExecutionListeners(listener);
launcher.execute(request);
return listener.getSummary().getFailures().isEmpty() ? ExitStatus.SUCCESS : ExitStatus.FAILURE;
}
示例7: getAsInt
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
@Override
public int getAsInt() {
ClassLoader oldContext = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try {
ModuleReference moduleReference = ModuleHelper.getOnlyModule(testPath);
Launcher launcher = LauncherFactory.create();
return launch(moduleReference, launcher);
} finally {
Thread.currentThread().setContextClassLoader(oldContext);
}
}
示例8: JUnit5TestUnitFinder
import org.junit.platform.launcher.core.LauncherFactory; //导入依赖的package包/类
public JUnit5TestUnitFinder() {
launcher = LauncherFactory.create();
}