user3697171
user3697171

Reputation: 69

test junit in command line

I try to test a junit class from the command line. I compile with this command

javac -d $ROOT/bin -extdirs $ROOT/jacorb-3.4/lib test/*.java

Now the .class are in the folder bin. I try this command

pwd
/Users/alex/Documents/assignment03/implementation
noname:implementation alexi$ ls
README.txt      jacorb-3.4      runServer.sh
bin         jacorb.env      runTest.sh
build.sh        junit.jar       src
buildTests.sh       out         test.log
idl         repo.ior
implementation.iml  runClient.sh
noname:implementation alex$ java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore bin.TestSII
JUnit version 4.10
Could not find class: bin.TestSII

Time: 0,002

OK (0 tests)

and still get Could not find class UPDATE

/Users/alex/Documents/assignment03/implementation/bin/test
noname:test alex$ cd ..
noname:bin alex$ ls
client          repo.ior        test
hamcrest-core-1.3.jar   server          test.log
junit-4.11.jar      stock
noname:bin alex$ pwd
/Users/alex/Documents/assignment03/implementation/bin
noname:bin alex$ ls
client          repo.ior        test
hamcrest-core-1.3.jar   server          test.log
junit-4.11.jar      stock
noname:bin alex$ cd ..
noname:implementation alex$ ls
README.txt      jacorb-3.4      runServer.sh
bin         jacorb.env      runTest.sh
build.sh        junit.jar       src
buildTests.sh       out         test.log
idl         repo.ior
implementation.iml  runClient.sh
noname:implementation alex$ java -cp /usr/share/java/junit.jar:bin org.junit.runner.JUnitCore TestSII
JUnit version 4.10
Could not find class: TestSII

Time: 0,001

OK (0 tests)

UPDATE 2

/Users/alex/Documents/assignment03/implementation
noname:implementation alex$ ls
README.txt      jacorb-3.4      runServer.sh
bin         jacorb.env      runTest.sh
build.sh        junit.jar       src
buildTests.sh       out         test.log
idl         repo.ior
implementation.iml  runClient.sh
noname:implementation alex$ cd bin
noname:bin alex$ ls
client          repo.ior        test
hamcrest-core-1.3.jar   server          test.log
junit-4.11.jar      stock
noname:bin alex$ cd test
noname:test alex$ ls
TestAMI.class   TestCBK.class   TestDII.class   TestSII.class
noname:test alex$ 

Upvotes: 0

Views: 287

Answers (2)

Sajan Chandran
Sajan Chandran

Reputation: 11487

Your class TestSII is inside test folder under bin. So just add bin folder to your classpath, and execute something like.

java -cp /usr/share/java/junit.jar:<bin folder location> org.junit.runner.JUnitCore test.TestSII

Upvotes: 1

John Farrelly
John Farrelly

Reputation: 7459

Try adding the bin directory to your classpath and removing it from the class to be executed:

java -cp /usr/share/java/junit.jar:$ROOT/bin org.junit.runner.JUnitCore TestSII

Upvotes: 0

Related Questions