gpt4 book ai didi

selenium - junit.framework.AssertionFailedError : No tests found in register

转载 作者:行者123 更新时间:2023-12-02 19:45:10 24 4
gpt4 key购买 nike

我在使此测试用例正常工作时遇到问题。有人能指出我正确的方向吗?我知道我做错了什么,但我不知道是什么。

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 和 4 的测试运行程序是不同的,我的假设是当 JUnit 看到您扩展了 TestCase 时,它​​会使用旧的运行程序。

删除 @Test 注释,而是遵循旧的约定,即使用前缀“test”来命名测试,这样就可以解决问题。

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

PPS。这是 link这更详细地解释了这一点。

关于selenium - junit.framework.AssertionFailedError : No tests found in register,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10097132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com