Migrating from 2.x to 3.0

JWebUnit was migrated internally to use JUnit 4 API instead of old JUnit 3. While it should be unnoticed for most end users, here are a few things you should check.

1. Replace all occurrence of junit.framework.AssertionFailedError by java.lang.AssertionError. For example if you have code like this:

    try {
        setTextField("nonexistent", "anyvalue");
        fail("Expected AssertionFailedError");
    } catch (AssertionFailedError e) {
        //OK it was expected
    }
	
Replace it with:
    try {
        setTextField("nonexistent", "anyvalue");
        fail("Expected AssertionError");
    } catch (AssertionError e) {
        //OK it was expected
    }
    
Or better use JUnit 4 expected feature: @Test(expected=AssertionError.class)

2. Update your tests and add explicit browser closing to your tests. With JUnit 4 you are not forced to extend a base class like TestCase, so we did the same for JWebUnit. You can remove "extends WebTestCase". As a result there is no more automatic closing of the browser. You have to manually define a "closeBrowser" call in your test cases (or in an abstract class from which all your tests will inherit). You should also add a static import on JWebUnit class containing all the methods that were previously in WebTestCase.

import static net.sourceforge.jwebunit.junit.JWebUnit.*;
    
public class MyTest {
    
    @Test
    public void myTest() {
        beginAt("http://google.fr");
        ...
    }
    
    @After
    public void close() {
        closeBrowser();
    }
}