【问题标题】:"Could not find class" in JUnitJUnit中的“找不到类”
【发布时间】:2012-12-18 06:53:54
【问题描述】:

我正在使用 AIX 机器运行一些 JUnit 测试。这些测试在 Eclipse 中使用适用于 Windows 和 Linux 平台的 JUnit 运行良好。我正在尝试使用 JUnit 命令行运行这些测试,但出现以下错误

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

Time: 0.012

OK (0 tests)

文件作为 testName.java 存在于该位置。我已经在 /etc/profile 文件中设置了我的环境变量。这些是我的环境变量。

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

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

在 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)

JUnit 网站 http://junit.sourceforge.net/doc/faq/faq.htm#tests_1 提供的默认位置中不存在 AllTests 类

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

可能出了什么问题?

【问题讨论】:

    标签: java linux junit junit4 aix


    【解决方案1】:
    org.junit.tests.AllTests
    

    发错地方了,就在这里

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

    应该是

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

    【讨论】:

      猜你喜欢
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      • 2011-05-16
      相关资源
      最近更新 更多