Created
July 12, 2019 06:06
-
-
Save ezhov-da/da22369a17c929b221d642dc45c74df6 to your computer and use it in GitHub Desktop.
Запуск JUnit тестов из командной строки
This file contains 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
==> https://stackoverflow.com/questions/2235276/how-to-run-junit-test-cases-from-the-command-line | |
For JUnit 5.x it's: | |
java -jar junit-platform-console-standalone-<version>.jar <Options> | |
Find a brief summary at https://stackoverflow.com/a/52373592/1431016 and full details at https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher | |
For JUnit 4.X it's really: | |
java -cp .:/usr/share/java/junit.jar org.junit.runner.JUnitCore [test class name] | |
But if you are using JUnit 3.X note the class name is different: | |
java -cp .:/usr/share/java/junit.jar junit.textui.TestRunner [test class name] | |
You might need to add more JARs or directories with your class files to the classpath and separate that with semicolons (Windows) or colons (UNIX/Linux). It depends on your environment. | |
Edit: I've added current directory as an example. Depends on your environment and how you build your application (can be bin/ or build/ or even my_application.jar etc). Note Java 6+ does support globs in classpath, you can do: | |
java -cp lib/*.jar:/usr/share/java/junit.jar ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment