版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、A1,测试驱动的设计和开发基础文章,Charles Huang import JUnit . framework . Test suite;import JUnit . framework . test;public class accountdaomysqltest extends test case public accountdaomysqltest(string name)super(name);a27、JUnit (sample)、2.overridesetUp()和teardown()(如果需要),请在setUp()中选择Database Connection、File I/O或T
2、earDown()上的资源(Database Connection、File I/O和Mock Objects等)public class accountdaomysqltest extends test case privationpublic void setup()throw inxception mysqlfixturins . setup();public void teardown()throw ind exception MySQL fixturins . teardown();a28、Junit(A sample)、3。为测试的Method创建test case public
3、void testaddaccountnormal()accountdaycommsql Dao=new Account dayscomple(),Account=newTry dao.addAccount(帐户);account account _ new=Dao . findbyusername(account . get username();Assertequals (expecting Charles,account . get username()account _ new . get username();Assert equals (expecting Charles,acco
4、unt . get password()account _ new . get password();Assert equals (expecting,account . getemail()account _ new . getemail();Dao . remove account(account . get username();catch(final exception e)e . print stack trace();fail(unexpected exception 3363603360 e . tostring();a29、JUnit (a sample)、public voi
5、d testaddaccountalreadyxist()accountdaycommysql Dao=null;Account=nulltry/add an account Dao . add account(帐户);fail(accountalreadyxistexception expected);catch(final sqlexception e)e . print stack trace();fail(unexpected exception 3363603360 e . tostring();catch(final accountnotfoundexception not fou
6、nd)not found . print stack trace();fail(unexpected exception : not found . tostring();catch(final accountalreadyxistexception ex)/passtry pdao . remove account(account . get username();catch(final sqlexception SQL)SQL . printstacktrace();故障排除(Unexpected exception,fail);A30,JUnit,运行此设备测试。Junit位于swing
7、(JUnit . swing ui . test runner)c : sandboxforumjava-class path ./classes;/lib/JUnit . jar;/lib/MySQL _ JDBC . jar;/lib/tidy . jar;/lib/struts . jar JUnit . swing ui . Test runner org . redsoft . forum . Dao . MySQL . accountdaomysqltest,a31,JUnit (a sample)public class all tests public static void
8、main(string args)JUnit . text ui . test runner . run(suite();public static test suite()test suite=new test suite();/添加到子程序包中的alltest suite suite . add test(org . redsoft . forum . Dao . MySQL . all tests . suite();/添加到此package level的unit test case suite . add test suite(mysqldatasource test . class)
9、中。Return suite/EOC、a34、JFC Unit、Junit的扩展,用于测试基于摆动的应用程序。最简单的:示例测试之一是Login Screen、a35、JFC Unit,代码片断:测试首选参数private log ins creen log ins creen=null;Private TestHelper helper=nullpublic loginscreentest(string name)super(name);protectedvoidsetup()throw inxception super . setup();helper=new JFCTestHelper(
10、);log inscreen=new log inscreen(log inscreen test : get name();log in screen . set visible(true);protected void tear down()throws exception log ins creen=null;helper . clean up(this);super . tear down();代码片断:测试图形界面JDialog dialogj button exit button=(j button)helper . findnamedcomponent(exit button,l
11、ogins creen,0);assert not null(could not find the exit button,exit button);jbutton enter button=(j button)helper . findnamedcomponent(enter button,loginscreen,0);assert not null(could not find the enter button,enter button);JT field username field=(JT field)helper . findnamedcomponent(login name tex
12、tfield,loginscreen,0);assert not null(could not find the username field,username field);Asser tequals(username field is empty,username field . get text();jtfield password field=(jtfield)helper . findnamedcomponent(password textfield,loginscreen,0);assert not null(could not find the password field,pa
13、ssword field);assert equals(password field is empty,password field . get text();a36、对Nightly Test使用Ant、Ant的Tasks自动运行Nightly Test生成XML示例结果报告,并生成可以使用JunitReport导航的结果文件。a37,测试案例复盖范围,使用NOUnit测试案例复盖范围(,a38,单位测试:100%始终,如果单位测试出现错误(Junit的进度指示器中显示红色),XP团队的第一个任务是Junit进度如果不更正错误的测试示例,则会产生雪球效应,因此,基于未知质量代码进行开发只会增加未知质量的代码。软件质量的基石开始崩塌。A39、Software Q
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 呼吸系统用药的护理监护
- 2026年上海市长江农场职工医院医护人员招聘笔试备考题库及答案详解
- 2026年度济宁市市级机关公开遴选公务员考试模拟试题及答案详解
- 鼻炎的饮食调理
- 2026年湖南建投四建集团有限公司项目经理招聘考试模拟试题及答案详解
- 2026西藏自治区医院(四川大学华西医院西藏医院)第二批招聘28人笔试模拟试题及答案详解
- 2026南网能源公司第一批项目制用工招聘18人考试模拟试题及答案详解
- 2026中国港口协会招聘外事及综合文秘岗1人笔试备考试题及答案详解
- 2026西藏日喀则定日县社会招聘涉税辅助人员2人考试参考题库及答案详解
- 2026年江铜铜箔科技股份有限公司第三批次春季校园招聘2人考试参考题库及答案详解
- 中国行业分类及代码
- LY/T 3037-2018乙酰化木材
- GB/T 3871.12-2005农业拖拉机试验规程第12部分:使用试验
- GB/T 21944.1-2022碳化硅特种制品反应烧结碳化硅窑具第1部分:方梁
- GB/T 19362.1-2003龙门铣床检验条件精度检验第1部分:固定式龙门铣床
- 海南大学2023-2023物理化学A卷试题、答案
- FZ/T 64012-2013卫生用水刺法非织造布
- 拉丁美洲和巴西【知识精讲+思维导图+拓展提升】高中 区域地理 主题探究式复习课件
- 网站界面(UI)设计形考作业5(实训9)参考答案
- 监控室值班记录
- 小学班主任带班育人方略5000字七篇
评论
0/150
提交评论