• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in Jweb Unit

 
prathana balaji
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import junit.framework.TestSuite;
import net.sourceforge.jwebunit.junit.WebTestCase;
import junit.framework.Test;
import junit.framework.TestCase;
import net.sourceforge.jwebunit.util.*;
import net.sourceforge.jwebunit.util.TestingEngineRegistry;


public class GoogleTest extends WebTestCase {
public static String searchLink = "";

public GoogleTest(String name)
{
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
}


public void setup() {
//setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
getTestContext().setBaseUrl("http://www.google.com");
}


public void testSearch() {
beginAt("/");
assertFormElementPresent("q");
setFormElement("q", "HttpUnit");
submit("btnG");
assertLinkPresentWithText(searchLink);
clickLinkWithText(searchLink);
}

public static void main(String[] args) {
searchLink = args[0];
junit.textui.TestRunner.run(new TestSuite(GoogleTest.class));
}

}


For the above code,While running the testcase from the command prompt I am getting the Following error
There was 1 failure:
1) warning(junit.framework.TestSuite$1)junit.framework.AssertionFailedError: Exc
eption in constructor: testSearch (java.lang.NullPointerException
at net.sourceforge.jwebunit.junit.WebTestCase.setTestingEngineKey(WebTes
tCase.java:1766)
at GoogleTest.<init>(GoogleTest.java:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at GoogleTest.main(GoogleTest.java:37)
)
at GoogleTest.main(GoogleTest.java:37)

FAILURES!!!
Tests run: 1, Failures: 1, Errors: 0


Please help me in soving this problem

REgards,
Prathana
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest that you take a look at WebTestCase.java line 1766 and see what might cause a NPE in that line.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic