【问题标题】:JWebUnit testing issueJWebUnit 测试问题
【发布时间】:2016-01-11 16:21:26
【问题描述】:

我得到空点异常。不知道我在这里做错了什么。我得到的错误是 java.lang.NullPointerException for goToLogintest1() beginAt("someJspFile")

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!");
    }

}

【问题讨论】:

  • 我不知道beginAt() 做了什么,但如果它访问文件,不应该将它包装在try catch 中吗?如果要访问的文件丢失,如果我正确,程序将崩溃。
  • 这是我从 [jwebunit.github.io/jwebunit/] 获得示例的地方

标签: java jsp junit jwebunit


【解决方案1】:

测试无法打开“someJspFile.jsp”页面,页面地址错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-08
    相关资源
    最近更新 更多