本文介绍了单元测试遗留ASP.NET Web表单应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承,有没有单元测试中有一个传统的Web应用程序。我想补充一些,但我在哪里开始亏损。我应该将它们添加到老code?或者只是新的code继续向前迈进?如果是code与传统的code相互作用?你有什么建议?

I've inherited a legacy web application that has no unit tests in it. I'd like to add some, but am at a loss of where to start. Should I add them to old code? Or just new code going forward? What if that code interacts with legacy code? What would you suggest?

推荐答案

首先,我会建议单元测试前进的所有变化,我想大多数人都会同意这是回归是个好主意。

First, I would recommend unit testing all changes going forward, I think most everyone would agree this is a good idea for regression.

不过,现有的code,这是那些你需要看你多大的风险是愿意还是允许引入到产品中的情况之一。问题是,当你开始进行单元测试现有的code的基础上,你会很快意识到了重构和设计改进的机会。

However, for existing code, this is one of those situations where you need to look at how much risk you're willing or allowed to introduce into the product. The problem is that when you start to unit test an existing code base, you're going to soon realize many opportunities for refactoring and design refinement.

请相信我,如果你是一个很讲究很好的设计,但你没有权力做出重大重构descisions,你只会落得一个破碎的心脏,当您尝试编写测试遗留的部分 - 是的,如果它没有现有的测试套件,其将需要重构。如果你不能让高冲击更改生产应用程序,你将最终实现我们喜欢称之为垃圾​​适配器模式的东西。祝你好运!

Take it from me, if you're a stickler for good design, but you haven't been empowered to make drastic refactoring descisions, you're only going to end up with a broken heart when you try to write tests for the legacy parts -- and yes, if it doesn't have existing test suite its going to NEED refactoring. If you're not allowed to make high impact changes to the production application, you're going to end up implementing something we like to call the "garbage adapter pattern". Good luck!

这篇关于单元测试遗留ASP.NET Web表单应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 20:13