Selenium junit.framework.AssertionFailedError:在注册表中未找到任何测试

Selenium junit.framework.AssertionFailedError:在注册表中未找到任何测试,selenium,junit,selenium-rc,Selenium,Junit,Selenium Rc,我在让这个测试用例工作时遇到了问题。谁能给我指出正确的方向吗?我知道我做错了什么,我只是不知道是什么 import org.junit.*; import com.thoughtworks.selenium.*; import org.openqa.selenium.server.*; @SuppressWarnings("deprecation") public class register extends SeleneseTestCase { Selenium selenium;

我在让这个测试用例工作时遇到了问题。谁能给我指出正确的方向吗?我知道我做错了什么,我只是不知道是什么

import org.junit.*;
import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.*;

@SuppressWarnings("deprecation")

public class register extends SeleneseTestCase {

  Selenium selenium;
  private SeleniumServer seleniumServer;
  public static final String MAX_WAIT = "60000";
  public final String CRN = "12761";

  public void setUp() throws Exception {
    RemoteControlConfiguration rc = new RemoteControlConfiguration();
    rc.setAvoidProxy(true);
    rc.setSingleWindow(true);
    rc.setReuseBrowserSessions(true);

    seleniumServer = new SeleniumServer(rc);
    selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://google.com/");
    seleniumServer.start();
    selenium.start();
  }

  @Test
  public void register_test() throws Exception {
    //TESTS IN HERE
  }

  @After
  public void tearDown() throws Exception {
    selenium.stop();
    // Thread.sleep(500000);
  }
}
我得到了以下错误:

junit.framework.AssertionFailedError: No tests found in register
at jumnit.framework.TestSuite$1.runTest(TestSuite.java:97)

我被难住了

您不能既扩展TestCase(或SeleniumTestCase),又使用JUnit注释(@Test)。JUnit3和JUnit4的测试运行程序是不同的,我的假设是,当JUnit看到您已经扩展了TestCase时,它会使用旧的运行程序

删除@Test注释,改为遵循旧的惯例,使用前缀“Test”来命名测试,这将修复它

public void testRegister() throws Exception {
  //TESTS IN HERE
}
另外,我建议遵循更标准的Java命名约定,例如驼峰式大小写


PPS。这里有一个更详细的解释。

在我的例子中,我通过指向1.7或更高版本的Ant,解决了这个错误——也就是说,使用
Ant任务运行测试。Ant1.7+支持嵌套的
元素,其中我指的是JUnit4.xJAR,正如CodeSpelunker所指出的,它理解@Test注释。这意味着你没有在下面的测试用例类中创建以test开头的方法名,你当前运行的是什么?我在Kotlin for Android中使用的是
mock
,我遇到了这个错误

我的类声明如下(由Android Studio自动生成):

但是删除TestCase修复了错误

class MyClassTest {
class MyClassTest {