使用junit的简单问题
这几段话怎么理解?需要被测试的代码写在什么地方?
1.Create a subclass of TestCase:
package junitfaq;
import java.util.*;
import junit.framework.*;
public class SimpleTest extends TestCase {
public SimpleTest(String name) {
super(name);
}
2.Write a test method to assert expected results on the object under test:
public void testEmptyCollection() {
Collection collection = new ArrayList();
assertTrue(collection.isEmpty());
}
3.Write a suite() method that uses reflection to dynamically create a test suite containing all the testXXX() methods:
public static Test suite() {
return new TestSuite(SimpleTest.class);
}
4.Write a main() method to conveniently run the test with the textual test runner:
public static void main(String args[]) {
junit.textui.TestRunner.run(suite());
}
}