分享
 
 
 

JUnit Test Infected: Programmers Love Writing Tests

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

早就对Junit有所耳闻,一直没时间一窥其究。太懒了,昨天终于决定研究一下这个东西。下面是其主页上的一篇入门文章,俺试着翻译一下:)

JUnit Test Infected: Programmers Love Writing Tests

Testing is not closely integrated with development. This prevents you from measuring the progress of development- you can't tell when something starts working or when something stops working. Using JUnit you can cheaply and incrementally build a test suite that will help you measure your progress, spot unintended side effects, and focus your development efforts.

Contents

The Problem

Example

Testing Practices

Conclusions

The Problem

Every programmer knows they should write tests for their code. Few do. The universal response to "Why not?" is "I'm in too much of a hurry." This quickly becomes a vicious cycle- the more pressure you feel, the fewer tests you write. The fewer tests you write, the less productive you are and the less stable your code becomes. The less productive and accurate you are, the more pressure you feel.

Programmers burn out from just such cycles. Breaking out requires an outside influence. We found the outside influence we needed in a simple testing framework that lets us do a little testing that makes a big difference.

The best way to convince you of the value of writing your own tests would be to sit down with you and do a bit of development. Along the way, we would encounter new bugs, catch them with tests, fix them, have them come back, fix them again, and so on. You would see the value of the immediate feedback you get from writing and saving and rerunning your own unit tests.

Unfortunately, this is an article, not an office overlooking charming old-town Zürich, with the bustle of medieval commerce outside and the thump of techno from the record store downstairs, so we'll have to simulate the process of development. We'll write a simple program and its tests, and show you the results of running the tests. This way you can get a feel for the process we use and advocate without having to pay for our presence.

Junit让程序员爱上测试

往往来说,测试和开发并不是紧密地集成在一起的,这会让妨碍你估量开发的进度-你不清楚一些东西什么时间开始工作或者停止工作。用Juint你可以创建一个简单的、增量式的测试集合,帮助你评估开发的进度,spot unintended side effects,集中精力进行你的开发。

目录

问题

例子

测试练习

结论

问题

每个程序员都清楚应该为自己的代码写一些测试,但很少有人会这样做。通常对于这个问题的回答就是“我太忙了,要赶进度啊!”。很快这就成为一个恶性循环-压力越大,你写的测试越少。你写的测试越少,你写出来的高质量的代码就越少并且将很不稳定。并且将接着导致你承受更大的压力。

程序员的精力就在这样的恶性循环中被耗费掉。想要打破它需要一种外界的影响。我们发现所谓的这种外界的影响,其实就是一个简单的测试框架,它可以让我们通过做很少的测试,但是你会发现有一些很大的不同。

让你认识到写自己的测试的价值的最好的办法就是坐下来进行一点开发。在此过程中,我们会遇到一些bugs,通过测试找到bug,修复bug,然后再测试,发现bug再修复等等。你会发现从你写测试,进行测试和重复测试中获得的及时反馈很有利用价值。

当然,这里只是一篇文章,不是an office overlooking charming old-town Zürich, with the bustle of medieval commerce outside and the thump of techno from the record store downstairs,所以我们只能模仿开发的进行情况。会给出一些简单的程序和它的测试,并展示执行测试的结果。通过这样你可以明白一些我们用到的步骤,然后以后即使我们不说你也会提倡这样做。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有