Hi,
thanks for help. Now the constructor works, but my testLogin() method
doesn't. Maybe the documentation
(http://jwebunit.sourceforge.net/quickstart.html) is somehow out-of-date?
I changed the code to:
public class LoginTest extends WebTestCase {
public LoginTest(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
super.setUp();
getTestContext().setBaseUrl("http://localhost:8080/modulverwaltung");
}
public void testLogin() {
assertFormPresent("entryform");
}
public static void main(String[] args) {
LoginTest test = new LoginTest("LoginTest");
test.testLogin();
}
}
The error message is:
Exception in thread "main" java.lang.NullPointerException
at
net.sourceforge.jwebunit.junit.WebTestCase.assertFormPresent(WebTestCase.java:605)
at test.LoginTest.testLogin(LoginTest.java:25)
at test.LoginTest.main(LoginTest.java:37)
It seems that the internal tester is null.
I looked in the source code of the runBare() method (on
http://jwebunit.sourceforge.net/xref/net/sourceforge/jwebunit/junit/WebTestCase.html),
where it says:
55 public void runBare() throws Throwable {
56 try {
57 tester=new WebTester();
58 super.runBare();
59 } finally {
60 tester=null;
61 }
62 }
Actually, I don't understand why a WebTester is initialized and then
again set to null.
Any idea what to do?
Best regards,
Abid
Julien HENRY schrieb:
> Hello,
>
> Just don't call getTestContext() in the constructor.
> Internal WebTester is initialized at in the runBare
> method.
>
> You should instead write something like:
>
> public class LoginTest extends WebTestCase {
> public void setUp() {
> super.setUp();
>
> getTestContext().setBaseUrl("http://localhost:8080/modulverwaltung");
> }
>
> ++
>
> Julien
>
> --- Abid Hussain <[EMAIL PROTECTED]> a écrit :
>
>> Hi everybody,
>>
>> I can't get JWebUnit started. I have all the jars
>> from the
>> jwebunit-1.4.1 in my classpath, including the
>> jwebunit-core-1.4.1.jar
>> and the jwebunit-htmlunit-plugin-1.4.1.jar and my
>> local Tomcat is running.
>>
>> My Test Case looks like this:
>> public class LoginTest extends WebTestCase {
>>
>> public LoginTest(String name) {
>>
>> super(name);
>>
>>
> getTestContext().setBaseUrl("http://localhost:8080/modulverwaltung");
>> }
>>
>> //...
>>
>> public static void main(String[] args) {
>>
>> LoginTest test = new LoginTest("LoginTest");
>> }
>> }
>>
>> When I run the main-method (from within eclipse), I
>> get following message:
>> Exception in thread "main"
>> java.lang.NullPointerException
>> at
>>
> net.sourceforge.jwebunit.junit.WebTestCase.getTestContext(WebTestCase.java:106)
>> at test.LoginTest.<init>(LoginTest.java:15)
>> at test.LoginTest.main(LoginTest.java:33)
>>
>> Anybody got an idea what's wrong?
>>
>> Best regards,
>>
>> Abid Hussain
>>
>> --
>>
>> Abid Hussain
>> Mail: [EMAIL PROTECTED]
>> Web: http://www.abid76.de
>>
>>
> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems?
>> Stop.
>> Now Search log events and configuration files using
>> AJAX and a browser.
>> Download your FREE copy of Splunk now >>
>> http://get.splunk.com/
>> _______________________________________________
>> JWebUnit-users mailing list
>> [email protected]
>>
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
>
>
> _____________________________________________________________________________
> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> JWebUnit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
--
Abid Hussain
Mail: [EMAIL PROTECTED]
Web: http://www.abid76.de
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users