1

I am getting null point exception. Not sure what I am doing wrong here. Error I get is java.lang.NullPointerException for goToLogin and test1() at 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!");
    }

}
user557657
  • 856
  • 1
  • 12
  • 35
  • I am not aware of what `beginAt()` does but if it accesses files shouldn't it be wrapped in a try catch? If the file to be accessed is missing the program will crash if im correct. – Mic1780 Jan 11 '16 at 17:22
  • This is where I get the example from [https://jwebunit.github.io/jwebunit/] – user557657 Jan 11 '16 at 17:52

1 Answers1

0

Tests can't open "someJspFile.jsp" page, wrong address for page.

Vika Marquez
  • 353
  • 1
  • 3
  • 12