我在一个测试类中有很多弹簧测试方法。我只想进行选择性测试。所以我想在同一个班级创建一个测试套件。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/testApplicationContext.xml"})
@TransactionConfiguration(defaultRollback=true)
public class TestersChoice {
@Test
@Transactional
public void testAddAccount(){
///do something ....
}
@Test
@Transactional
public void testDeleteAccount(){
///do something ....
}
@Test
@Transactional
public void testReadAccount(){
///do something ....
}
}
如果我运行这个 Class TestersChoice,所有测试都会运行!我只想运行 testReadAccount 而不是其余的。我想创建套件来运行选择性测试。(我想避免删除 @Test 以上测试方法来实现这一点)类似于 jUnit testcase 的东西。这就是我能够通过将 TestersChoice 类扩展到 TestCase 并插入此方法来做到的:
public static TestSuite suite(){
TestSuite suite = new TestSuite();
suite.addTest(new TestersChoice("testDeleteAccount"));
return suite;
}
但是现在我没有扩展 TestCase 所以我无法将 TestersChoice 实例添加到套件中!
如何进行选择性测试?