本站首页    管理页面    写新日志    退出


«August 2025»
12
3456789
10111213141516
17181920212223
24252627282930
31


公告

关注电子政务、大型企业应用开发、Web、Workflow、MOM、MDA、RCP、GEF

email:gmluyang@gmail.com


链接

好友
bluedavy-林昊
刑红瑞
SixSun-翻译
Birt中文指南
SixSun-OpenDoc
Eclipse RCP and Web in action(编写中)

我的分类(专题)

日志更新

最新评论

留言板


Blog信息
blog名称:SixSun的Blog
日志总数:152
评论数量:372
留言数量:13
访问次数:2380428
建立时间:2004年12月13日




[软件测试]利用JUNIT进行单元测试(下)
文章收藏,  网上资源,  软件技术

SixSun 发表于 2004/12/17 22:20:47

5.    编写测试代码 /*  * Created on 2004-2-9  *  * To change the template for this generated file go to  * Window>Preferences>Java>Code Generation>Code and Comments  */ package com.yjsoft.test;   import junit.framework.Assert; import junit.framework.TestCase; import com.yjsoft.app.HelloWorld;   /**  * @author yanghx2004  *  * To change the template for this generated type comment go to  * Window>Preferences>Java>Code Generation>Code and Comments  */ public class HelloWorldTest extends TestCase {     /**      * Constructor for HelloWorldTest.      * @param arg0      */     public HelloWorldTest(String arg0) {        super(arg0);     }       public static void main(String[] args) {        junit.swingui.TestRunner.run(HelloWorldTest.class);     }     public void testSayHello() {        HelloWorld world=new HelloWorld();        //Assert.assertNull(world);        assertEquals(world.sayHello(),"Hello World");     }     public void testAdd() {        HelloWorld world=new HelloWorld();        //Assert.assertNull(world);        Assert.assertEquals(world.add(1,2),3);     } }   6.    测试 500)this.width=500'> 发现失败,方法为sayHello(),看看具体信息“应为Hello word. 却发现 Hello World” 修改测试函数 assertEquals(world.sayHello(),"Hello world."); 7.    测试,通过 8.    500)this.width=500'>   关于JUNIT简单使用就介绍这么多, 关于用JUNIT来模拟请求进行JSP测试,我下次讲解。这要涉及到HttpUnit单元。


阅读全文(3336) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.234 second(s), page refreshed 144759844 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号