I'm trying to run tests from the command line (PowerShell in Windows 10). Before asking this question I looked in several sources and read a lot of topics, like
- How to run JUnit test cases from the command line
- https://github.com/junit-team/junit4/wiki/Getting-started
But when I'm trying to run tests from PowerShell like in JUnit wiki
cd E:\Dev\AutoTest\Example
java -cp .;/libs/junit-4.12.jar;/libs/hamcrest-core-1.3.jar org.junit.runner.JUnitCore tests.Booking.BookingTests
I get the output
CommandNotFoundException
If I run the same, but via old command line (cmd.exe
):
cd E:\Dev\AutoTest\Example
java -cp .;E:\Dev\AutoTest\Example\libs\junit-4.12.jar;E:\Dev\AutoTest\Example\libs\hamcrest-core-1.3.jar org.junit.runner.JUnitCore tests.Booking.BookingTests
I get the output
java.lang.IllegalArgumentException: Could not find class [tests.Booking.BookingTests] Caused by: java.lang.ClassNotFoundException: tests.Booking.BookingTests
In IDEA the project structure look like this:
On the hard drive the structure look like this:
• "out" folder cointains *.class files
• "src" folder contains *.java files
The question:
How to run JUnit test cases from the command line in PowerShell with my structure?