SE450: Testing: Junit Tests [48/63] |
Create a test class. (Test classes are object classes.)
Each test method is treated like a separate program.
import junit.framework.Assert; import junit.framework.TestCase; public class TEST1 extends TestCase { public TEST1(String name) { super(name); } public void testA() { ... } public void testB() { ... } }
Tests are run more-or-less as:
TEST1 t1 = new TEST1("testA"); t1.setUp(); t1.testA(); t1.tearDown(); TEST1 t2 = new TEST1("testB"); t2.setUp(); t2.testB(); t2.tearDown();
Each test has one of three possible outcomes:
Rules for a test class: