单元测试指南 [英] unit testing guidelines

查看:89
本文介绍了单元测试指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已根据自己的经验编制了一套og单元测试

建议

的概念。


反馈和改进建议

表示赞赏:

http://geosoft.no/development/unittesting.html

谢谢。

I have compiled a set og unit testing
recommendations based on my own experience
on the concept.

Feedback and suggestions for improvements
are appreciated:

http://geosoft.no/development/unittesting.html

Thanks.

推荐答案

-----开始PGP签名消息-----

哈希:SHA1

NotDashEscaped:您需要GnuPG验证此消息


Jacob uitte de volgende tekst op 03/18/2006 12:03 AM:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Jacob uitte de volgende tekst op 03/18/2006 12:03 AM:
我编写了一套og单元测试
基于我自己的建议关于这个概念的经验。

反馈和改进建议
非常感谢:

http://geosoft.no/development/unittesting.h tml
I have compiled a set og unit testing
recommendations based on my own experience
on the concept.

Feedback and suggestions for improvements
are appreciated:

http://geosoft.no/development/unittesting.html




干得好。


我不完全赞同第16点:投票声明意味着*可能*被抛出,并且应该记录这可能发生的情况。很少会抛出异常。


您可能想要对assertX方法的内容做一些解释。


H.

-

Hendrik Maryns


==================
www.lieverleven.be
http://aouw.org

----- BEGIN PGP SIGNATURE -----

版本:GnuPG v1.4.2(GNU / Linux)

iD4DBQFEHEUxe + 7xMGD3itQRAsFwAKCBXX77fVjeMGJz3 + AU0B xe / pYnoQCY5z2F

Ti5C4PCNnHJBSHbz3tp2jQ ==

= VsD2

----- END PGP SIGNATURE -----



Nice work.

I don''t totally agree with point 16: a throws statement means an
exception *might* be thrown, and the circumstances under which this can
happen should be documented. It is seldom that an exception must be thrown.

You might want to give some explanation about what you assertX methods do.

H.
--
Hendrik Maryns

==================
www.lieverleven.be
http://aouw.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD4DBQFEHEUxe+7xMGD3itQRAsFwAKCBXX77fVjeMGJz3+AU0B xe/pYnoQCY5z2F
Ti5C4PCNnHJBSHbz3tp2jQ==
=VsD2
-----END PGP SIGNATURE-----


文章< dv *************@news.t-online.com>,

Hendrik Maryns< he ************ @ despammed .COM>写道:
In article <dv*************@news.t-online.com>,
Hendrik Maryns <he************@despammed.com> wrote:
-----开始PGP签名消息-----
哈希:SHA1
NotDashEscaped:您需要GnuPG验证此消息

Jacob uitte de volgende tekst op 03/18/2006 12:03 AM:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Jacob uitte de volgende tekst op 03/18/2006 12:03 AM:
我根据自己的经验编写了一套og单元测试建议
反馈和改进建议
非常感谢:

http://geosoft.no/development/unittesting.html
I have compiled a set og unit testing
recommendations based on my own experience
on the concept.

Feedback and suggestions for improvements
are appreciated:

http://geosoft.no/development/unittesting.html



干得好。

我不完全同意第16点:抛出语句意味着可能会抛出异常*,并且应该记录这种情况发生的情况。很少会抛出异常。



Nice work.

I don''t totally agree with point 16: a throws statement means an
exception *might* be thrown, and the circumstances under which this can
happen should be documented. It is seldom that an exception must be thrown.




我同意。只测试你真正希望客户端代码依赖的内容。

现在,如果你想让客户端代码依赖于抛出

异常的方法...

-

魔术取决于传统和信仰。它不欢迎观察,

也不会通过实验获利。另一方面,科学的经验基于
;它可以通过观察和实验进行修正。



I agree. Only test what you actually want the client code to rely on.
Now if you want the client code to rely on the method throwing an
exception...
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.


Jacob写道:
我编写了一套og单元测试
建议为基础根据我自己的经验
关于概念。

反馈和改进建议
非常感谢:

http://geosoft.no/development/unittesting.html
I have compiled a set og unit testing
recommendations based on my own experience
on the concept.

Feedback and suggestions for improvements
are appreciated:

http://geosoft.no/development/unittesting.html



我''添加0点 - 首先写测试。


8 - 名字应该更具表现力,而不是testSaveAs(),怎么样?
a系列测试,testSaveAsCreatesANewFile(),

testSaveAsSavesCuentdataInNewFile()等。经常用广泛的名字测试

试图测试太多广告不表达他们的意图。


第0点涵盖第11点。


13 - 小心随机数字,它们可能会导致失败

难以r eproduce。我会使用一个可重复的伪随机序列

给定的种子。


0和8覆盖14.


0涵盖17.


0涵盖20.


-

Ian Collins 。


I''d add point 0 - write the tests first.

8 - names should be more expressive, rather than testSaveAs(), how about
a series of tests, testSaveAsCreatesANewFile(),
testSaveAsSavesCuentdataInNewFile() etc. Often tests with a broad name
attempt to test too much ad don''t express their intent.

Point 0 covers point 11.

13 - take care with random numbers, they can lead to failures that are
hard to reproduce. I''d use a pseudo-random sequence that is repeatable
with a given seed.

0 and 8 covers 14.

0 covers 17.

0 covers 20.

--
Ian Collins.


这篇关于单元测试指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆