我在Java中学习TDD。我做了一个简单的下面的测试课: -
public class EnrollingServiceTest extends TestCase {
private EnrollingService enrollingService;
public EnrollingServiceTest( String testName )
{
super( testName );
}
@Before
public void init() {
enrollingService = new EnrollingService();
}
@Test
public void testEnroll() {
boolean result = enrollingService.enroll(1l, 1l);
assertTrue(result);
}
}
我提出了一个断点来调试测试执行。我发现永远不会调用init()。首先调用构造函数然后调用testEnroll()。为什么@Before不被Junit框架调用?