Last active
October 15, 2021 16:45
-
-
Save Slayug/d017c5d97b4f014f6b2648e8ca06b31b to your computer and use it in GitHub Desktop.
Running JUnit 5 Tests programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* You need the following dependencies in your classpath: | |
* junit-platform-console | |
* junit-platform-launcher | |
* junit-jupiter-engine | |
**/ | |
import org.junit.platform.console.options.CommandLineOptions; | |
import org.junit.platform.console.options.Details; | |
import org.junit.platform.console.options.Theme; | |
import org.junit.platform.console.tasks.ConsoleTestExecutor; | |
import java.io.PrintWriter; | |
import java.util.Collections; | |
public class JUnit5Runner { | |
public static void main(String[] args) throws Exception { | |
CommandLineOptions options = new CommandLineOptions(); | |
options.setSelectedPackages(Collections.singletonList("io.toast.test")); | |
options.setBannerDisabled(true); | |
options.setTheme(Theme.UNICODE); | |
options.setDetails(Details.TREE); | |
new ConsoleTestExecutor(options).execute(new PrintWriter(System.out)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment