Djunit安装和简单使用

转载自: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】

 

[java]  view plain copy
  1. public class DjunitDemo {  
  2.     /** 
  3.      * print n's state 
  4.      */  
  5.     public void testDemo(int n) {  
  6.         if (n > 0) {  
  7.             System.out.println("n>0");  
  8.         } else if (n < 0) {  
  9.             System.out.println("n<0");  
  10.         } else {  
  11.             System.out.println("n=0");  
  12.         }  
  13.     }  
  14.     /** 
  15.      * return n(n>=0) -n(n<0) 
  16.      */  
  17.     public int getInt(int n)  
  18.     {  
  19.         if (n>=0) {  
  20.             return n;  
  21.         } else {  
  22.             return -n;  
  23.         }  
  24.     }  
  25. }  
 

 

 

3.4 编写测试类,比如【Djunit】

 

[java]  view plain copy
  1. import jp.co.dgic.testing.framework.DJUnitTestCase;  
  2. public class Djunit extends DJUnitTestCase  {  
  3.     public final void testTestDemo() {  
  4.         DjunitDemo demo = new DjunitDemo();  
  5.         demo.testDemo(-1);  
  6.         demo.testDemo(1);  
  7.         demo.testDemo(0);  
  8.     }  
  9.       
  10.     public final void testGetInt() {  
  11.         DjunitDemo demo = new DjunitDemo();  
  12.         assertEquals(1, demo.getInt(1));  
  13.         assertEquals(1, demo.getInt(-1));  
  14.     }  
  15. }  
 

 

 

3.5 运行

右键 -> run as -> djunit,djunit面板中会显示结果

 

3.6 ok了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值