问题描述
我有一个现有的 asp.net webforms 应用程序,我想向其中添加一些单元测试,但不确定如何去做.
I have an existing asp.net webforms application that I would like to add some unit testing to but am unsure of exactly how to go about it.
该应用程序是具有功能的数据库驱动,我想您可以将其与高级论坛进行比较.逻辑、数据访问和呈现大部分是分开的.
The application is database driven with functionality I guess you could compare to an advanced forum. Logic, data access and presentation are seperated for the most part.
我应该测试哪些方法?
如何处理数据库和测试数据?
How do I handle the database and test data?
有没有推荐的工具可以帮助解决这个问题?
Are there any tools recommended to assist in this?
推荐答案
您需要决定的第一件事是:您添加单元测试的动机是什么?
The first thing you need to decide is: What is your motivation for adding unit tests?
进行单元测试有很多很好的理由(我自己严格实践 TDD),但是知道哪个是您的案例的主要驱动力应该有助于您决定首先编写哪些测试.
There are many excellent reasons for having unit tests (I rigorously practice TDD myself), but knowing which one is the main driving force in your case should help you decide which tests to first write.
在大多数情况下,您应该专注于为过去给您带来最大痛苦的应用领域编写单元测试.
In most cases you should concentrate on writing unit tests for the areas of your application that have been causing you the most pain in the past.
大量经验表明,当软件最初是在没有单元测试的情况下编写的,随后很难改进单元测试.有效地使用遗留代码 提供了关于如何有效地使用旧代码的宝贵指导使未经测试的软件项目可测试.
Much experience has shown that when software originally was written without unit tests, it can be hard to subsequently retrofit unit tests. Working Effectively with Legacy Code provides valuable guidance on how to make an untested software projects testable.
这篇关于将单元测试添加到现有的 asp.net web 表单应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!