将单元测试添加到现有的 asp.net web 表单应用程序

Adding unit testing to an existing asp.net web forms application(将单元测试添加到现有的 asp.net web 表单应用程序)
本文介绍了将单元测试添加到现有的 asp.net web 表单应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的 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 表单应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)