Java 类org.junit.platform.launcher.TestExecutionListener 实例源码
项目:mastering-junit5
文件:LauncherApiExample.java
@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);
}
项目:Mastering-Software-Testing-with-JUnit-5
文件:LauncherApiExample.java
@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);
}
项目:jovial
文件:JovialSocketLauncher.java
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);
}
}
项目:jovial
文件:JovialSocketLauncher.java
private static TestExecutionListener createListener(SocketChannel channel) {
try {
OutputStream baseStream = Channels.newOutputStream(channel);
ObjectOutputStream stream = new ObjectOutputStream(baseStream);
return new SerializingListener(stream);
} catch (IOException e) {
throw new UncheckedIOException("Failed to open stream to socket client.", e);
}
}