1

I'm developing a C# application to run JUnit tests automatically. Since it's complicated to move the current location where my C# application is running, i need to execute the JUnit tests without directly go inside their folder.

So, i have this folder tree:

» ProjectFolder

»» ClassesFolder

»» TestsFolder

»»» testX.java

»»» testX.class

I'm already able to compile the files, using:

javac ...\ProjectFolder\ClassesFolder\*.java
javac ...\ProjectFolder\TestsFolder\*.java

But i can't execute the tests. I tried:

java -classpath ...\ProjectFolder org.junit.runner.JUnitCore TestsFolder.testX

And got this error:

Error: Could not find or load main class org.junit.runner.JUnitCore

I even try this way:

java org.junit.runner.JUnitCore ...\ProjectFolder TestsFolder.testX

But, once again, it doesn't work:

JUnit version 4.10
Could not find class: -classpath
Could not find class: ...\ProjectFolder
Could not find class: TestsFolder.testX

Time: 0,003

OK (0 tests)

So, my main doubt, is how i can use the options (like -cp or -classpath) of the java command, when executing JUnit tests using org.junit.runner.JUnitCore.

Thanks in advance.

1 Answer 1

2

The problem is that the jUnit-runner is not in the classpath you specify. You need to add the path to junit.jar to the classpath.

Google is nice http://www.jsystemtest.org/?q=node/44

But why not just use something that already exists and can take care of this? Like Maven or Ant?

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, Tobb! I'd already set my classpath with junit.jar and another libraries that i need, but when i tried to use the option -classpath, i forgot to indicated it again. About Maven and Ant, i've read some articles about it, maybe i'll use it. Thank's for the tip. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.