JUnit测试实战:高效测试与报告生成指南
1. 测试用例类命名规范
为了方便文件集的包含操作,同时排除辅助类或基础测试用例类,需要对测试用例类的命名方案进行标准化。通常的命名约定是,只有测试用例类的名称以“Test”结尾。例如, HtmlDocumentTest 是测试用例类,而 DocumentTestCase 是抽象基类。对于抽象测试用例,我们使用“TestCase”作为后缀。
2. 任务配置
<junit> 任务的配置示例如下:
<junit printsummary="true" haltonfailure="true">
<classpath refid="test.classpath"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${test.data.dir}">
<fileset dir="${test.dir}" includes="**/*Test.class"/>
</batchtest>
</junit>
includes 子句确保只考虑具体的测试用例类,而不包括抽象的 DocumentTestCase 类。将非 JUnit 类或抽
超级会员免费看
订阅专栏 解锁全文
1039

被折叠的 条评论
为什么被折叠?



