【发布时间】:2014-09-13 08:46:20
【问题描述】:
在下面的测试类中,我的测试对象没有被初始化,因为之前没有被调用。
有什么想法吗?
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class CalcDateToolTest extends TestCase
{
DatesCalculator calc;
@Before
public void initialize() {
System.out.println("Before");
calc = new DatesCalculator("15/06/2013", "30/06/2013");
}
@Test
public void testCalcDayDiff() {
assertEquals(true, calc.getFromDate());
}
@After
public void destroy() {
calc = null;
}
}
【问题讨论】:
-
你为什么删除你的旧帖子?那时我对相关问题发表评论是对的......可能会有答案:stackoverflow.com/a/733358/1993402。结论:
do NOT extend TestCase AND use annotations at the same time!