junit白盒测试java

junit白盒测试java

ID:12713018

大小:64.00 KB

页数:10页

时间:2018-07-18

junit白盒测试java_第1页
junit白盒测试java_第2页
junit白盒测试java_第3页
junit白盒测试java_第4页
junit白盒测试java_第5页
资源描述:

《junit白盒测试java》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、计算机科学与技术系实验报告专业名称软件工程课程名称软件测试项目名称白盒测试之赋税管理系统班级12级软件工程学号1204091034姓名常成同组人员实验日期2014/10/13一、实验内容:利用白盒测试之赋税管理系统练习基本路径测试方法。二、实验目的与要求:实验目的:基本路径测试方法练习收入Income和供养人数nDependance来计算赋税金额的程序。程序输入是Income和nDependance,程序输出是:总税金TaxTotal应缴所得税计算公式:TaxSubtotal收入(income)税率计算公式<100000.02*i

2、ncome10000£income<50000200+0.03*(income-10000)³500001400+0.04*(income-50000)免税部分:exemption=人数*50;实缴所得税:TaxTotal=TaxSubtotal–exemption实验要求:使用java语言实现。画出该程序的控制流图计算圈复杂度获取基本路径设计测试用例,使得每条基本路径都要覆盖到。三、实验步骤1、算法实现(附上源代码)程序Java代码:packageProject.com.cn.test;importjava.util.Scann

3、er;publicclassTexTotal{privatedoubletotals;privatedoubleincome;privateintper;publicdoublegettotals(){returntotals;}publicvoidsetShuru(doubleincome,intper){this.income=income;this.per=per;}publicbooleangetShuru(){try{Scannerin=newScanner(System.in);System.out.println("

4、请输入你的工资和家庭人数(以空格隔开):");this.income=in.nextInt();this.per=in.nextInt();}catch(Exceptione){System.out.println("请输入正确的工资数目!");System.out.println("错误类型:"+e);returnfalse;}returntrue;}publicvoidIncome(){if(this.income<=0

5、

6、this.per<=0){System.out.println("请输入正确的家庭人数和收入!");}e

7、lseif(this.income<10000){this.totals=this.income*0.02-this.per*50;}elseif(this.income>=10000&&this.income<50000){this.totals=200+(this.income-10000)*0.03-this.per*50;}else{this.totals=1400+(this.income-50000)*0.04-this.per*50;}if(this.totals<0){this.totals=0;}}publicv

8、oidPrints(){System.out.println("需要缴纳的税为:"+this.totals);}publicstaticvoidmain(Stringargs[]){TexTotald=newTexTotal();if(d.getShuru()){d.Income();d.Prints();}}}测试代码:packageProject.com.cn.test;importstaticorg.junit.Assert.*;importjunit.framework.Assert;importorg.junit.Aft

9、er;importorg.junit.Before;importorg.junit.Test;publicclassTexTotalTest{TexTotals=newTexTotal();@BeforepublicvoidsetUp()throwsException{}@AfterpublicvoidtearDown()throwsException{}@TestpublicvoidtestGetShuru1(){s.setShuru(9994,5);s.Income();Assert.assertEquals(0.0,s.ge

10、ttotals());}@TestpublicvoidtestGetShuru2(){s.setShuru(10023,3);s.Income();Assert.assertEquals(50.69,s.gettotals());}@Testpub

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。