简体   繁体   中英

“Could not find class” in JUnit

I am using AIX machine to run few JUnit tests. These tests work fine in eclipse using JUnit for Windows and Linux platforms. I am trying to run these tests using JUnit command line and I am getting following error

# 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. I have set my environment variables in /etc/profile file. These are my environment variables.

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

export 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.

# 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

# 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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