Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Use JUnit CN
Revision as of 02:35, 3 October 2006 by Young.yz.gmail.com (Talk | contribs)
本文论述如何在Eclipse 中使用JUnit 进行单元测试。
Contents
基本概念
- TestRunner
- TestCase
- TestSuite
使用说明
- 新建sample 项目,源文件夹为src。
- 新建并实现Triangle 类,包名为com.ime.sample。
- 新建源文件夹test。
- 新建并实现TriangleTest 类,包名为com.ime.sample.test。
- 使用JUnit 运行TriangleTest。
- 重构TriangleTest 和Triangle 类。
与Ant 结合生成测试报告
- 新建并实现build.xml 文件在sample 项目中。
- 使用Ant 运行build.xml。
- 在浏览器中查看测试报告。