• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in Jweb Unit

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic