开始使用自动化集成/单元测试在现有的代码库 [英] Getting started with automated integration/unit testing in an existing code base

查看:185
本文介绍了开始使用自动化集成/单元测试在现有的代码库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我们一直交给一个非常大的代码库(140万线)即主要在C#。该应用程序主要由asp.net 2.0风格的ASMX Web服务在SQL Server 2008数据库,并在不同的XML文件中访问数据。有没有适当的现有自动化测试。我们有一个自动化每日构建到位(CC.NET)。

Background: We have been handed over a very large codebase (1.4 million lines) that is primarily in C#. The application consists primarily of asp.net 2.0 style asmx web services accessing data in a SQL server 2008 database and also in various XML files. There are no existing automated tests in place. We have an automated nightly build in place (CC.NET).

我们希望引入自动化测试的一些水平,但在重构粒度级别单元测试这一数额的代码似乎不太可能。我们首先想到的是要找到一种方法来构建自动化测试只需调用每个Web服务使用一组给定的参数给我们的代码覆盖率一定程度。好像获得代码覆盖率的最高金额与一些自动化测试的最快方法。难道这甚至被称为单元测试,或将本被认为是别的东西吗?

We want to introduce some level of automated testing, but refactoring in granular level unit tests for this amount of code seems unlikely. Our first thought is to find a way to construct automated tests that simply call each web service with a given set of parameters to give us some level of code coverage. Seemed like the quickest way to get the highest amount of code coverage with some automated tests. Is this even called unit testing or would this be considered something else?

我怎么会去隔离数据存储,以获得一致的检测结果?是否有任何测试工具工作,这种方法比别人更好?的xUnit? MS测试吗? NUnit的?

How would I go about isolating the data stores to get consistent test results? Would any test tools work better for this approach than others? xUnit? MS tests? NUnit?

任何建议,让我们在正确的方向开始将不胜感激。谢谢

Any suggestions to get us started in the right direction would be greatly appreciated. Thanks

推荐答案

我公司一直在做我们的代码库(C,而不是C#)类似的东西,总计约一万行。这些步骤都走了这样的事情:

My company has been doing something similar with our code base (C rather than C#) that totals about a million lines. The steps have gone something like this:

1)写一些自动化测试像你描述做系统级测试结果
2)实施规则。新的代码应具有一个单元测试。结果
3)当一个区域有一些错误反对修复这些bug应该包括编写一个基本的单元测试的过程。

1) Write some automated tests like you describe that do system level tests.
2) Implement the rule that new code shall have a unit test.
3) When an area has a few bugs against it the process of fixing those bugs should include writing a basic unit test.

的一点是,3不应该要求一个完整的单元测试(如果它是比较容易的人会做)。如果从0%的测试覆盖率移动到特定的模块,那么你已经取得了很大的进步,40%的覆盖率。

The point is that 3 shouldn't require a complete unit test (if it's easier people will do it). If you move from 0% test coverage to 40% coverage of a particular module then you've made great progress.

虽然6个月,你可能只达到5总的代码库%有5%是变化最多和你最有可能引入错误,其中的代码。我对现在的工作的代码是约60%由单元测试覆盖的集成测试和15%(按行)覆盖。 ,这似乎并不像很多,但它确实提供显著的价值和我们的发展努力从中受益

Though 6 months in you may only be up to 5% of the total code base that 5% is the code that is changing the most and where you are most likely to introduce bugs. The code I work on now is about 60% covered by integration tests and 15% (by line) covered by unit tests. That doesn't seem like a lot but it does provide significant value and our development effort has benefited from it.

编辑:的回应其他评论一个当前的一组集成测试,我们运行需要约14小时的时刻。现在我们正在寻找一些运行并行加速起来。

edit: in response to one of the other comments the current set of integration tests we run take about 14 hours at the moment. We're now looking at running some in parallel to speed them up.

这篇关于开始使用自动化集成/单元测试在现有的代码库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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