我尝试从命令行测试junit类。我用这个命令编译
javac -d $ ROOT / bin -extdirs $ ROOT / jacorb-3.4 / lib test / * .java
现在.class位于文件夹bin中。我试试这个命令
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)
仍然无法找到课程 的更新
/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)
更新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$
答案 0 :(得分:1)
您的班级TestSII
位于test
下的bin
文件夹中。
因此,只需将bin
文件夹添加到classpath
,然后执行类似。
java -cp /usr/share/java/junit.jar:<bin folder location> org.junit.runner.JUnitCore test.TestSII
答案 1 :(得分:0)
尝试将bin
目录添加到类路径中,并将其从要执行的类中删除:
java -cp /usr/share/java/junit.jar:$ROOT/bin org.junit.runner.JUnitCore TestSII