找不到 class JUNIT org.junit.runner.JUnitCore

Could not find class JUNIT org.junit.runner.JUnitCore

我有框架

创建的测试class
import org.selenium.MainTestCase;

public class Test01 extends MainTestCase {

  @Override
  public void setUp() throws Exception {
    super.setUp();
    startSeleniumSession("RemoteWebDriver", "http://102.0.0.01:8080/hello/");
  }

  public void testMethod() throws Exception {

        session().open("/hello/request.co","");
        session().selectFrame("top_frame");
        session().type("id=lgn:username","test");
        session().type("id=lgn:password","test");
        session().click("id=lgn:submit");
        session().waitForFrameToLoad("top_frame","");
  }

  @Override
  public void tearDown() throws Exception {
    super.tearDown();
  }

}

我有bat文件

javac -cp .\lib\* Test01.java
java -cp .\lib\* org.junit.runner.JUnitCore Test01

在 lib 文件夹中,我有为我生成 Test01 class 的所有 jar 和框架。

当我 运行 我的 bat 文件时,我得到了结果:

JUnit 版本 4.10 找不到 class:Test01 时间:0,002 好的(0 个测试)

classes 和 libs 的结构是:

根文件夹 - dist

lib 文件夹(在 dist 下)- 我所有的库都放在那里

dist 文件夹中我有 Test01.classTest01.java 以及 run.bat

您需要使用 . 将当前目录添加到类路径中。在基于 windows 的系统上,您使用 ; 分隔文件夹,而在基于 unix 的系统上,您使用 :.

分隔文件夹

Windows 示例:my/path/1;.(添加路径 my/path/1 和当前目录)

Unix 示例:my/path/1:.(添加路径 my/path/1 和当前目录)