Regression Tests

TestNG

  • Successor of JUnit

  • Same Idea

  • Easier to use

  • TestNG Homepage

  • Eclipse plugin available

What you need to do:

  • Write a normal class

  • Test functions throw Exception

  • Test functions are annotated with @Test

  • Assert class for basic tests

  • Assert.fail()

Maven Use:

Example 2. Example TestNG Tests
import org.testng.Assert;
import org.testng.annotations.Test;

/**
 * Tests for {@link Blabla}.
 */
public class VirtualFileTest {

    /**
     * Tests the add function.
     * 
     * @throws Exception
     *             if the test fails.
     */
    @Test
    public void addTest() throws Exception {
        Blabla b = new Blabla(4);
        b.add(5);
        Assert.assertEquals(b.getValue(), 9);
    }

    @Test
    public void divideTest() throws Exception {
       Blabla b = new Blabla(4);
       try {
          b.divide(0);
          Assert.fail();
       catch (IllegalArgumentException e) {
          // Good!
       }
    }
}

Other Test Frameworks

The following framework may help in GUI testing: