1 2 3 | public class GoogleTest extends WebTestCase { static String searchLink = ""; } |
1 2 3 4 | public static void main(String[] args) { searchLink = args[0]; junit.textui.TestRunner.run(new TestSuite(GoogleTest.class)); } |
1 2 3 4 5 | public void setUp() { getTestContext().setBaseUrl("http://www.google.com"); getTestContext().setProxyName("proxy.host.com"); getTestContext().setProxyPort(80); } |
1 2 3 4 5 6 7 8 | public void testSearch() { beginAt("/"); assertFormElementPresent("q"); setFormElement("q", "HttpUnit"); submit("btnG"); assertLinkPresentWithText(searchLink); clickLinkWithText(searchLink); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | C:\temp>java com.jweb.test.GoogleTest "HttpUnit Hwee" .F Time: 5.338 There was 1 failure: 1) testSearch(com.jweb.test.GoogleTest)junit.framework.AssertionFailedError: Link with text [HttpUnit Hwee] not found in response. at net.sourceforge.jwebunit.WebTester.assertLinkPresentWithText(WebTester.java:618) at net.sourceforge.jwebunit.WebTestCase.assertLinkPresentWithText(WebTestCase.java:244) at com.jweb.test.GoogleTest.testSearch(GoogleTest.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at com.jweb.test.GoogleTest.main(GoogleTest.java:19) FAILURES!!! Tests run: 1, Failures: 1, Errors: 0 |
1 2 3 4 | C:\temp>java com.jweb.test.GoogleTest "HttpUnit Home" . Time: 6.991 OK (1 test) |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |