Skip to content

Instantly share code, notes, and snippets.

@ttddyy
Created November 22, 2015 16:44
Show Gist options
  • Save ttddyy/6ebe7044a37aadd6febb to your computer and use it in GitHub Desktop.
Save ttddyy/6ebe7044a37aadd6febb to your computer and use it in GitHub Desktop.
launcher to run junit5 tests
package org.springframework.test.context.junit5;
import org.junit.gen5.console.ColoredPrintingTestListener;
import org.junit.gen5.engine.TestPlanSpecification;
import org.junit.gen5.launcher.Launcher;
import org.junit.gen5.launcher.listeners.SummaryCreatingTestListener;
import org.junit.gen5.launcher.listeners.TestExecutionSummary;
import java.io.PrintWriter;
/**
* @author Tadaya Tsuyukubo
*/
public class SpringExtensionTestsLauncher {
public static void main(String[] args) {
Launcher launcher = new Launcher();
TestPlanSpecification testPlanSpecification = TestPlanSpecification.build(
TestPlanSpecification.forPackage("org.springframework.test.context.junit5")
);
TestExecutionSummary summary = new TestExecutionSummary();
launcher.registerTestPlanExecutionListeners(new SummaryCreatingTestListener(summary));
launcher.registerTestPlanExecutionListeners(new ColoredPrintingTestListener(System.out, false));
launcher.execute(testPlanSpecification);
try (PrintWriter writer = new PrintWriter(System.out)) {
summary.printFailuresOn(writer);
summary.printOn(writer);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment