我在我的应用程序中编写了一个selenium样本测试用例。然后我右键单击该文件并选择“测试文件”。结果
Testsuite: com.MyApp.SampleSeleniumTest
Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.265 sec
Testcase: warning(junit.framework.TestSuite$1): FAILED
No tests found in com.MyApp.SampleSeleniumTest
junit.framework.AssertionFailedError: No tests found in com.MyApp.SampleSeleniumTest
Test com.MyApp.SampleSeleniumTest FAILED
我的代码是
package com.MyApp;
import com.thoughtworks.selenium.*;
import org.junit.Test;
public class SampleSeleniumTest extends SeleneseTestCase {
@Override
public void setUp() throws Exception {
setUp("http://www.google.com", "*firefox");
}
@Test
public void whatever() throws Exception {
selenium.open("/");
assertTrue(selenium.isTextPresent("Explore"));
}
}
答案 0 :(得分:1)
这是另一种做同样的方法
package com.MyApp;
import com.thoughtworks.selenium.*;
import org.junit.*;
public class SampleSeleniumTest extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://urlofyourApp");
selenium.start();
}
@Test
public void testTestRC() throws Exception {
selenium.open("/");
assertTrue(selenium.isTextPresent("Explore"));
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}