0

我正在尝试使用 JWebUnit 框架对我的 servlet 进行集成测试。我所做的只是将所需的两个 jar 文件 (jwebunitcorejwebunit-htmlunit-plgin) 导入到我的类路径中。这是代码:

package com.ec.projectName.server;

import static org.junit.Assert.*;
import net.sourceforge.jwebunit.junit.JWebUnit;
import net.sourceforge.jwebunit.util.TestingEngineRegistry;

import org.junit.Before;
import org.junit.Test;

public class ViewTest {

    @Before
    public void setUp() throws Exception {
        JWebUnit.setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
        JWebUnit.setBaseUrl("http://localhost:8080/projectName");
    }

    @Test
    public void test() {

        JWebUnit.beginAt("View.html");
        JWebUnit.assertTitleEquals("View result");
        JWebUnit.assertFormPresent();
        JWebUnit.assertFormElementPresent("preferred_name");
        JWebUnit.assertFormElementPresent("zip_Code");
    }
}

最后,我将其作为 junit 测试运行,并且我的 servlet 正在浏览器中运行,但结果仍然出现错误!

我在这里做错了吗?

4

0 回答 0