简体   繁体   English

JUnit中的“找不到类”

[英]“Could not find class” in JUnit

I am using AIX machine to run few JUnit tests. 我正在使用AIX机器运行一些JUnit测试。 These tests work fine in eclipse using JUnit for Windows and Linux platforms. 使用Windows和Linux平台上的JUnit,这些测试在eclipse中运行良好。 I am trying to run these tests using JUnit command line and I am getting following error 我正在尝试使用JUnit命令行运行这些测试,但出现以下错误

# java org.junit.runner.JUnitCore testName
JUnit version 4.8.1
Could not find class: testName

Time: 0.012

OK (0 tests)

File is present at that location as testName.java. 文件在该位置显示为testName.java。 I have set my environment variables in /etc/profile file. 我已经在/ etc / profile文件中设置了环境变量。 These are my environment variables. 这些是我的环境变量。

export CLASSPATH=/usr/junit/junit-4.8.1.jar:/usr/junit/ 导出CLASSPATH = / usr / junit / junit-4.8.1.jar:/ usr / junit /

export PATH=$PATH=$PATH:/usr/junit/junit-4.8.1.jar:/usr/junit/ 导出PATH = $ PATH = $ PATH:/usr/junit/junit-4.8.1.jar:/ usr / junit /

On AIX machine when I try to test JUnit using following code, it gives me same failure. 在AIX机器上,当我尝试使用以下代码测试JUnit时,它也给我带来同样的失败。

# java org.junit.runner.JUnitCore org.junit.tests.AllTests
JUnit version 4.8.1
Could not find class: org.junit.tests.AllTests

Time: 0.012

OK (0 tests)

AllTests class was not present in default location provided on JUnit website http://junit.sourceforge.net/doc/faq/faq.htm#tests_1 JUnit网站http://junit.sourceforge.net/doc/faq/faq.htm#tests_1提供的默认位置中没有AllTests类。

# find / -name "*AllTests*"
/usr/junit/org/junit/runners/AllTests.class

What could be wrong? 有什么事吗

org.junit.tests.AllTests

is in the wrong place, it is here 在错误的地方,在这里

/usr/junit/org/junit/runners/AllTests.class

it should be 它应该是

/usr/junit/org/junit/tests/AllTests.class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM