我有這樣的代碼:JUnit TestCase功能如何實際工作?
public class MyTest extends TestCase {
private MyObject mObject1;
private MyObject mObject2;
...
@Override
public void setUp() throws Exception {
super.setUp();
}
public void testSomething() {
mObject1 = new MyObject();
mObject2 = new MyObject();
}
public void testSomething2() {
// Here I can't access the previously created objects mObject1 and
// mObject2, because they are again null.
// Why is that, if *my* setUp() method doesn't touch them?
}
我的猜測是,JUnit的再次每次實例化類。有人可以向我解釋工作流程嗎?
謝謝。
感謝您對TestNG的評論。我會看看! – kaneda