我得到了空点异常。我不知道我到底做错了什么。我得到的错误是goToLogin的java.lang.NullPointerException和beginAt("someJspFile")上的test1()
import net.sourceforge.jwebunit.junit.JWebUnit;
import net.sourceforge.jwebunit.util.TestingEngineRegistry;
import org.junit.Before;
import org.junit.*;
import static net.sourceforge.jwebunit.junit.JWebUnit.*;
import static net.sourceforge.jwebunit.junit.JWebUnit.setBaseUrl;
public class ServletTest {
@Before
public void prepare() {
JWebUnit.setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT); // use HtmlUnit
JWebUnit.setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_WEBDRIVER); // use WebDriver
}
public void setUp() throws Exception {
setBaseUrl("http://localhost:8080");
}
@Test
public void goToLogin() {
beginAt( "someJspFile.jsp" );
}
@Test
public void test1() {
beginAt("someJspFile.jsp");
setTextField("username", "test");
submit();
assertTitleEquals("Welcome, test!");
}
}发布于 2016-01-13 15:30:06
测试无法打开"someJspFile.jsp“页面,页面地址错误。
https://stackoverflow.com/questions/34726329
复制相似问题