什么是做ASP.NET 2.0 Web页面的单元测试的最好方法?

问题描述:

有什么建议?在C#中使用Visual Studio。

Any suggestions? Using visual studio in C#.

是否有用来处理这个任何特定的工具或方法?

Are there any specific tools to use or methods to approach this?

对不起,我应该多一点具体的。我使用ASP.Net 2.0并正在寻找更多像Java的JUnit的工具。我看了看NUnit的和NUnitAsp那看起来非常有前途。而我甚至不知道的Visual Studio Pro有一个测试套件,所以我会看看所有这些选项(我使用Visual Studio / Asp.net / C#今年夏天刚刚开始)。

Sorry, I should have been a little more specific. I am using ASP.Net 2.0 and was looking more for a tool like jUnit for Java. I took a look at NUnit and NUnitAsp and that looks very promising. And I didn't even know that Visual Studio Pro has a testing suite, so I'll look at all of these options (I've just started using Visual Studio/Asp.net/C# this summer).

男孩,这是一个pretty一般性的问题。我会尽我所能,但要ppared见我一大截错过$ P $。

Boy, that's a pretty general question. I'll do my best, but be prepared to see me miss by a mile.

假设

    \r
  1. 您正在使用ASP.NET,而不是普通的ASP
  2. \r
  3. 您真的不希望测试您的网页,但在逻辑甩在身后。单元测试的实际.ASPX网页是相当痛苦的,但也有框架,在那里做。 NUnitAsp 就是其中之一。
  4. \r
  1. You are using ASP.NET, not plain ASP
  2. You don't really want to test your web pages, but the logic behind them. Unit testing the actual .ASPX pages is rather painful, but there are frameworks out there to do it. NUnitAsp is one.

做的第一件事就是组织(或计划)的code,以便它可以进行测试。两种最流行的设计模式,这在当时似乎是MVP和MVC。无论从景观独立应用程序的逻辑离开,这样就可以测试逻辑没有得到你的方式的观点(网页)。

The first thing to do is to organize (or plan) your code so that it can be tested. The two most popular design patterns for this at the time seem to be MVP and MVC. Both separate the logic of the application away from the view so that you can test the logic without the view (web pages) getting in your way.

无论是MVP或MVC将是有效的。 MVC具有微软框架几乎准备去的优势。

Either MVP or MVC will be effective. MVC has the advantage of having a Microsoft framework almost ready to go.

一旦你选择了鼓励可测性的框架模式,您需要使用单元测试工具。 NUnit的是一个很好的起点。 Visual Studio的专业有一个测试套件建造它,但NUnit的+的TestDrive.NET 也能在IDE中。

Once you've selected a framework pattern that encourages testability, you need to use a unit testing tool. NUnit is a good starting point. Visual Studio Professional has a testing suite built it, but NUnit + TestDrive.NET also works in the IDE.

这是这类信息猎枪爆炸。我希望有如果它击中。语用书架有好书涵盖的话题

That's sort of a shotgun blast of information. I hope some if it hits. The Pragmatic Bookshelf has a good book covering the topic.