有如下单元测试类,请回答当用TestRunner执行该单元测试类时,输出结果是()
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class TestSimpleBean2 extends TestCase {
public TestSimpleBean2(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
System.out.println("setUp");
}
protected void tearDown() throws Exception {
super.tearDown();
System.out.println("tearDown");
}
public void testMethod() {
System.out.println("testMethod");
}
public void foo() {
System.out.println("foo");
}
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(new TestSimpleBean2("foo"));
return suite;
}
}
A. setUp
B. tearDown
C. testMethod
D. foo
面试公司给出的正确答案是:C
请大家自行决断,我不认为正确答案是C,我亲测输出如下,有没有大牛回答一下
setUp
foo
tearDown