问题描述
在使此测试用例正常工作时遇到了问题.谁能指出我正确的方向?我知道我做错了,我只是不知道什么.
I'm having a problem getting this test case to work. Can anyone point me in the right direction? I know I'm doing something wrong, I just don't know what.
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时,它将使用旧的运行程序.
You can't both extend TestCase (or SeleniumTestCase) and also use JUnit annotations (@Test). The test runners for JUnit3 and 4 are different, and my assumption is when JUnit sees that you've extended TestCase, it uses the old runner.
删除@Test批注,而是遵循旧的约定,即在测试之前加上单词"test",即可解决该问题.
Remove the @Test annotation, and instead follow the old convention of naming your test with the word "test" prefixed, and that will fix it.
public void testRegister() throws Exception {
//TESTS IN HERE
}
PS.我建议遵循更多标准的Java命名约定,例如骆驼套.
PS. I'd recommend following more standard Java naming conventions, such as camel casing.
PPS.这是一个链接,对此进行了详细说明.
PPS. Here's a link that explains this in more detail.
这篇关于junit.framework.AssertionFailedError:在寄存器中未找到测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!