Saturday 6 April 2013

Junit-3



TestCase- class should be inherited for the test case class where all the method starts 
with testX(),testY()

TestSuite- class should be inherited 

public class XTest extends TestCase {
    public File file;
    public XTest(File file) {
           super(file.toString());
           this.file = file;
    }
    public void testX() {
           fail("Failed: " + file);
    }
}
public class XTestSuite extends TestSuite {
    public static Test suite() {
           TestSuite suite = new TestSuite("XTestSuite");
           File[] files = new File(".").listFiles();
           for (File file : files) {
                       suite.addTest(new XTest(file));
           }
           return suite;
    }
}

No comments:

Post a Comment