my dog learned polymorphism*
The moose likes Testing and the fly likes Error in Jweb Unit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Error in Jweb Unit" Watch "Error in Jweb Unit" New topic
Author

Error in Jweb Unit

prathana balaji
Ranch Hand

Joined: Oct 07, 2007
Posts: 30
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

Joined: Jul 11, 2001
Posts: 14112
I'd suggest that you take a look at WebTestCase.java line 1766 and see what might cause a NPE in that line.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in Jweb Unit
 
Similar Threads
HttpUnit Help..
how to send a mail to yahoo user
Redirect requested but followRedirects is disabled
Cant read from other thread
sending email