I am trying to do integration test on my servlets with the JWebUnit framework. All I've done is importing the two jar files needed (jwebunitcore
and jwebunit-htmlunit-plgin
) into my class path. Here is the code:
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");
}
}
Finally I run this as junit test and my servlet is running in the browser, but I am still getting an error as result!
Am I doing something wrong here?