整个系统单元测试套件应多久运行一次? [英] how often should the entire suite of a system's unit tests be run?

查看:110
本文介绍了整个系统单元测试套件应多久运行一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我仍然是一个测试新生的单元.

Generally, I'm still very much a unit testing neophyte.

顺便说一句,您可能还会在xUnit.net等其他论坛上看到此问题,
因为这对我来说是一个重要的问题.我预先为我
交叉发布;您的意见对我非常重要,而不是每个人
在这个论坛上也属于其他论坛.

BTW, you may also see this question on other forums like xUnit.net, et cetera,
because it's an important question to me. I apoligize in advance for my
cross posting; your opinions are very important to me and not everyone
in this forum belongs to the other forums too.

我正在研究一个已有十年历史的旧式系统,该系统具有700多个单元测试.
最近写的(700只是一个小开始).测试碰巧是写的
在MSTest中,但此问题适用于所有测试框架AFAIK.

I was looking at a large decade old legacy system which has had over 700 unit tests
written recently (700 is just a small beginning). The tests happen to be written
in MSTest but this question applies to all testing frameworks AFAIK.

当我通过vs2008所有测试"进行跑步时,最终计数仅为7个测试.
这大约是迄今为止编写的所有测试的1%.

When I ran, via vs2008 "ALL TESTS", the final count was only seven tests.
That's about 1% of the total tests that have been written to date.

更多信息:ASP.NET MVC 2 RTM源代码,包括其单元测试,
在CodePlex上可用;这些单元测试也用MSTest
编写 即使(无关紧要的事实)布拉德·威尔逊(Brad Wilson)后来加入了ASP.NET MVC团队.
作为其高级程序员.所有2000多个测试都可以运行,而不仅仅是少数几个.

MORE INFORMATION: The ASP.NET MVC 2 RTM source code, including its unit tests,
is available on CodePlex; those unit tests are also written in MSTest
even though (an irrelevant fact) Brad Wilson later joined the ASP.NET MVC team
as its Senior Programmer. All 2000 plus tests get run, not just a few.

问题:考虑到AFAIK,单元测试的目的是识别损坏
在SUT中,我认为最佳实践"始终是正确的,
或至少非常频繁地运行所有测试?

QUESTION: given that AFAIK the purpose of unit tests is to identify breakages
in the SUT, am I correct in thinking that the "best practice" is to always,
or at least very frequently, run all of the tests?

更新了2010-05-22

首先,感谢所有提供出色答案的人.你的答案 确认我的一般结论,即在每次本地重建后运行所有单元测试是 最佳实践,无论是练习TDD(之前测试)还是经典 单元测试(之后测试).

First, thank you to everyone who has provided excellent answers. Your answers confirm my general conclusion that running all unit tests after every local rebuild is the best practice regardless whether one is practicing TDD (test before) or classic unit testing (test after).

恕我直言,这个问题有多个最佳答案,但AFAIK SO允许 我只选择一个,所以为了公平起见,我给了复选标记 皮特·约翰斯(Pete Johns)成为第一名,并获得了SO的最多票数 社区.芬兰的Esko Luontola也给出了很好的答案(我希望 他没有被火山灰埋没)和两个很好的联系 值得您珍惜我的时间;绝对是F.I.R.S.T.的链接.对我来说是鼓舞人心的; AFAIK,.NET世界中只有xUnit.net提供任何时间,任何顺序". Esko的第二个链接是一段92分钟的真正出色的视频集成测试是一个骗局" 由J. B.(Joe)Rainsberger提出( http://jbrains.ca 其中包含更多内容 值得我的时间).顺便说一句,Esko的博客也值得一游 http://orfjackal.net .

imho, there is more than one best answer to this question but AFAIK SO lets me select just one, so in an effort to be fair, I've given the check mark to Pete Johns for being first and for earning the most up votes from the SO community. Finland's Esko Luontola also gave a great answer (I hope he's not getting buried in volcanic ash) and two very good links that are worth your time imho; definitely the link to F.I.R.S.T. is to me inspirational; AFAIK, only xUnit.net in the .NET world offers the "any order, any time". Esko's second link is to a truly excellent 92 minute video "Integration Tests Are a Scam" presented by J. B. (Joe) Rainsberger ( http://jbrains.ca where there is more content worth my time). BTW, Esko's weblog is also worth a visit http://orfjackal.net.

推荐答案

由于您已将此问题标记为"TDD",因此应执行正在开发的模块的所有单元测试(并通过,禁止最新的测试,直到您使它通过)与每个编译.其他模块中的单元测试不应因当前模块中的开发而中断,否则它们将进行过多的测试.

Since you have tagged this question 'TDD', all of the unit tests for the module being developed should be executed (and pass, bar the newest one, until you make it pass) with every compilation. Unit tests in other modules should not break by development in the current module or else they are testing too much.

还应该建立一个连续的集成循环,以确保在每次检入源代码控制系统时都运行所有测试.这样可以尽早捕获破损.

A continuous integration loop should also be in place to ensure that all of the tests are run with every check-in to your source control system. This will trap breakages early.

至少,每晚构建应该运行每个测试,并且任何破损都应该在早晨固定下来.不能容忍任何单元测试失败!

At the very least, a nightly build should run each and every test and any breakages be fixed first thing of a morning. Tolerate no unit test failures!

这篇关于整个系统单元测试套件应多久运行一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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