转载自:http://blog.csdn.net/aotian16/article/details/5732298
1.下载Djunit
http://works.dgic.co.jp/djwiki/Viewpage.do?pid=@646A556E697420446F776E6C6F6164
2.安装
解压下载过来的文件到eclipse安装目录下的 plugins 目录中就OK了
3.简单使用
3.1 建立一个web工程,比如【TempDjunit】
3.2 导入djunit.jar,junit.jar到lib下
3.3 编写一个待测试类,比如【DjunitDemo】
- public class DjunitDemo {
- /**
- * print n's state
- */
- public void testDemo(int n) {
- if (n > 0) {
- System.out.println("n>0");
- } else if (n < 0) {
- System.out.println("n<0");
- } else {
- System.out.println("n=0");
- }
- }
- /**
- * return n(n>=0) -n(n<0)
- */
- public int getInt(int n)
- {
- if (n>=0) {
- return n;
- } else {
- return -n;
- }
- }
- }
3.4 编写测试类,比如【Djunit】
- import jp.co.dgic.testing.framework.DJUnitTestCase;
- public class Djunit extends DJUnitTestCase {
- public final void testTestDemo() {
- DjunitDemo demo = new DjunitDemo();
- demo.testDemo(-1);
- demo.testDemo(1);
- demo.testDemo(0);
- }
- public final void testGetInt() {
- DjunitDemo demo = new DjunitDemo();
- assertEquals(1, demo.getInt(1));
- assertEquals(1, demo.getInt(-1));
- }
- }
3.5 运行
右键 -> run as -> djunit,djunit面板中会显示结果
3.6 ok了