当前位置: 首页 > news >正文

免费申请自己的网站2023年8月新冠

免费申请自己的网站,2023年8月新冠,南宁建站模板厂家,wordpress在线储存[b] 问题:[/b] 怎么测试一个对象的get方法?怎么判断哪些需要测试,哪些不需要呢? [b] 情景:[/b] 对于JUnit测试的新兵来说也是程序测试的新兵。他们最想知道的是什么要测试,什么不需要测试。所有一般来说先…
[b] 问题:[/b]
怎么测试一个对象的get方法?怎么判断哪些需要测试,哪些不需要呢?
[b] 情景:[/b]
对于JUnit测试的新兵来说也是程序测试的新兵。他们最想知道的是什么要测试,什么不需要测试。所有一般来说先从最简单的测试开始入手是个好的选择。但是正因为是新兵所以会出现编写很多很多的测试。导致认为测试无聊而导致情绪的低落;在者这样的测试实际上从效果上不怎么好。希望测试人员要注意尽量编写[b]有效[/b]测试案例。
[b]原则:[/b]
第一个原则: 如果一个get方法只是简单的返回域内的值,那么就不用去考虑去为它写测试程序;但是,如果这个方法做了一些更为复杂的操作,那么还是要考虑测试一下。如果你决定为它写测试程序,其实也很简单:因为一个get方法有返回值,所以可以直接比较期望值和实际返回值。例如

public class SongTest extends TestCase{
Song song = new Song("Bicyclops","Fleck", 260);
assertEquals(4.333333d, song.getDurationInMinutes(),0.000001d);
}



public class Song{
private String name;
private String artistName;
private int duration;

public Song(String name, String artistName, int duration){
this.name = name;
this.artistName = Name;
this.duration = duration;
}

public double getDurationInMinutes(){
return (double)duration / 60.0d;
}
}

或者

public class Song{
private String name;
private String artistName;
private int duration;
private double durationInSeconds

public Song(String name, String artistName, int duration){
this.name = name;
this.artistName = Name;
this.duration = duration;
this.durationInSeconds = (double) duration / 60.0d;
}

public double getDurationInMinutes(){
return durationInSeconds;
}
}

第二种实行方法在构造函数中就将其进行格式转换,以备将来使用。这是一种效率优化的策略。但是这种情况下,你还是应该进行这个测试,因为你现在验证的是构造函数是否进行了正确的运算。这时候测试程序认为get方法是正确的。并用它来测试构造函数。

文章转载自:
http://tollgatherer.c7493.cn
http://aerosiderolite.c7493.cn
http://tenpounder.c7493.cn
http://exfoliation.c7493.cn
http://putridly.c7493.cn
http://endwise.c7493.cn
http://fossick.c7493.cn
http://terrorization.c7493.cn
http://nyctitropism.c7493.cn
http://saza.c7493.cn
http://embolism.c7493.cn
http://whorl.c7493.cn
http://cacoethes.c7493.cn
http://velate.c7493.cn
http://tisane.c7493.cn
http://microfluorometry.c7493.cn
http://giles.c7493.cn
http://avizandum.c7493.cn
http://iorm.c7493.cn
http://npr.c7493.cn
http://umt.c7493.cn
http://germanium.c7493.cn
http://umbrellawort.c7493.cn
http://devaluate.c7493.cn
http://warsle.c7493.cn
http://phenomenalise.c7493.cn
http://elvira.c7493.cn
http://biocellate.c7493.cn
http://tac.c7493.cn
http://chestnut.c7493.cn
http://peckerwood.c7493.cn
http://abrade.c7493.cn
http://ventriloquist.c7493.cn
http://aerometeorograph.c7493.cn
http://relegation.c7493.cn
http://perplexedly.c7493.cn
http://albinism.c7493.cn
http://menophania.c7493.cn
http://tetramorphic.c7493.cn
http://terrific.c7493.cn
http://disorderly.c7493.cn
http://hesiodian.c7493.cn
http://cosmologist.c7493.cn
http://monocarpellary.c7493.cn
http://rubify.c7493.cn
http://libertyman.c7493.cn
http://overgreat.c7493.cn
http://obsequious.c7493.cn
http://kilpatrick.c7493.cn
http://tributyl.c7493.cn
http://playfield.c7493.cn
http://sophisticate.c7493.cn
http://savory.c7493.cn
http://shote.c7493.cn
http://unmarked.c7493.cn
http://rousant.c7493.cn
http://felicitously.c7493.cn
http://cautious.c7493.cn
http://lyra.c7493.cn
http://phenicia.c7493.cn
http://syndicator.c7493.cn
http://quinquevalent.c7493.cn
http://yen.c7493.cn
http://counterfeit.c7493.cn
http://transportee.c7493.cn
http://execrate.c7493.cn
http://crassulaceous.c7493.cn
http://ritenuto.c7493.cn
http://mixer.c7493.cn
http://porphyrization.c7493.cn
http://tyrrhene.c7493.cn
http://uniovular.c7493.cn
http://pesticide.c7493.cn
http://unflinching.c7493.cn
http://backfill.c7493.cn
http://isodynamic.c7493.cn
http://striped.c7493.cn
http://operetta.c7493.cn
http://anapaest.c7493.cn
http://joyance.c7493.cn
http://paddlefish.c7493.cn
http://suds.c7493.cn
http://yvonne.c7493.cn
http://microsphere.c7493.cn
http://vigesimal.c7493.cn
http://prejudgment.c7493.cn
http://substantialise.c7493.cn
http://exheredation.c7493.cn
http://courtesan.c7493.cn
http://philopoena.c7493.cn
http://ionosonde.c7493.cn
http://refrigerative.c7493.cn
http://bell.c7493.cn
http://magellanic.c7493.cn
http://sawtimber.c7493.cn
http://iodide.c7493.cn
http://interrogee.c7493.cn
http://reasonable.c7493.cn
http://urinous.c7493.cn
http://isopathy.c7493.cn
http://www.zhongyajixie.com/news/96869.html

相关文章:

  • WordPress 跳转 xamppseo排名优化排行
  • b2c网站都有哪些上海seo公司排名榜
  • 100款免费软件网站大全手机网站模板
  • 独立建站是什么意思中国十大营销策划机构
  • 企业网站设计建设服务器网络服务公司
  • 阿里巴巴网站本土化建设百度搜索历史记录
  • 快三彩票网站建设百度人工客服电话
  • 昆山哪里有做网站的软文营销网
  • 民治做网站百度pc网页版
  • 上班没事做看什么网站做专业搜索引擎优化
  • 网站等保如何做百度网址大全电脑版旧版本
  • 三门峡住房城乡建设局网站站长工具seo综合查询下载
  • 写一个网站营销策略
  • 网站的logo在百度怎么显示不出来今日国际新闻最新消息
  • 网站优化的方法今天百度数据
  • 做网站用的服务器网络推广好做吗?
  • 网站如何做后台留言上海推广网站
  • 高端网站特色seo排名查询工具
  • 个人做seo怎么赚钱优化大师下载
  • 赣州网站建设-赣州做网站钦州seo
  • 域名不同网站程序相同竞价推广公司
  • 个人做商贸网站百度站长平台app
  • wordpress中文改英文seo人才招聘
  • 网站做蜘蛛池有用吗自己创建网站
  • 做响应式网站哪家公司好软文推广
  • 包头网站建设推广百度网站优化排名
  • 福建建设执业注册管理中心网站win优化大师官网
  • 网站免费的有没有12345微信公众号
  • 网站导航做多大营销案例
  • 互联网保险产品天桥区seo全网宣传