Reputation: 1442
I want to run my class in terminal window:
D:\workEclipse2\JUnitTest\bin>java -classpath D:\JUnit\hamcrest-core-1.3.jar;D:\
JUnit\junit-4.12.jar tax.TaxCommandLineRunner
Code of my TaxCommandLineRunner class:
package tax;
import java.util.List;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
public class TaxCommandLineRunner {
public static void main(String[] args) {
// TODO Auto-generated method stub
JUnitCore core = new JUnitCore();
Result result = core.run(AllTests.class);
if(result.wasSuccessful()){
System.out.println("All tax tests was successfull");
}else{
System.out.println("These tax tests was failure");
List<Failure> fails = result.getFailures();
fails.forEach(failure -> System.out.println(failure.getMessage()));
}
}
}
Compiled AllTests.class
and TaxCommandLineRunner.class
are located in D:\workEclipse2\JUnitTest\bin
.
My jars file are located in D:\JUnit
I can't find what I'm doing wrong.
Upvotes: 3
Views: 1277
Reputation: 1442
I input in terminal window:
D:\workEclipse2\JUnitTest\bin>java -classpath D:\JUnit\hamcrest-core-1.3.jar;D:\JUnit\junit-4.12.jar;. tax.TaxCommandLineRunner
I assume that point after semicolon means classpath of Windows, that is in first case I don't include my standart java\jre.
Upvotes: 1
Reputation: 69460
You must also add the actual directory to your classpath:
D:\workEclipse2\JUnitTest\bin>java -classpath .;D:\JUnit\hamcrest-core-1.3.jar;D:\
JUnit\junit-4.12.jar tax.TaxCommandLineRunner
Upvotes: 0