我使用Spring 3.0.4和JUnit 4.5。我的测试类目前使用Spring的注解测试支持的语法如下:Spring 3+如何在JUnit未识别时创建TestSuite
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration (locations = { "classpath:configTest.xml" })
@TransactionConfiguration (transactionManager = "txManager", defaultRollback = true)
@Transactional
public class MyAppTest extends TestCase
{
@Autowired
@Qualifier("myAppDAO")
private IAppDao appDAO;
...
}
我并不真的需要行扩展的TestCase运行该测试。当它自己运行这个测试类时不需要它。我不得不添加扩展的TestCase,这样我可以在TestSuite类添加:
public static Test suite() {
TestSuite suite = new TestSuite("Test for app.dao");
//$JUnit-BEGIN$
suite.addTestSuite(MyAppTest.class);
...
如果我省略了延伸的TestCase,我的测试套件将不会运行。 Eclipse将标记为suite.addTestSuite(MyAppTest.class)作为错误。
如何添加Spring 3+测试类到测试套件?我确定有更好的方法。我已经GOOGLE并阅读文档。如果你不相信我,我愿意把所有的书签都寄给你。但无论如何,我宁愿建设性的答案。非常感谢。
LOL。我再次搜索了一下,看到了关于Google搜索结果的问题。我会再次搜索:) – chris 2010-09-11 14:44:24
罗德约翰逊自己写道,“春天本身有一个很好的单元测试套件”(http://www.theserverside.com/news/1363858/Introduction-to-the-Spring-Framework)。这个优秀的测试套件在哪里被记录? – chris 2010-09-11 14:48:22
您提供的网址无效! – adranale 2012-05-25 10:46:40