ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Dillon" <paul.dil...@solnet.com.au>
Subject RE: JUnit example/readings
Date Tue, 26 Jun 2001 01:52:31 GMT
> Java Server Programming by Wrox has a chapeter on it.

Just a warning if you intend to buy online: I have the 1st edition of
this book which does not have anything on JUnit.

The documentation wasn't immediately clear to me either.  Easiest way to
get started is to:
1. create a class that extends TestCase
2. provide the constructor that takes a name string and calls
super(name)
3. for each test, provide a method with a name starting with "test".
4. use the assert methods to check for expected behaviour.

Eg:

public class SimpleTest extends junit.framework.TestCase {
    public SimpleTest(String name) {
        super(name);
    }
    public void testAdd() {
        int sum = 1 + 1;
        assertEquals(2, sum);
    }
}

Next step would be to override the setUp and tearDown methods.
Documentation is OK on this.

- Paul


Mime
View raw message