简体   繁体   English

将TDD与MVC3结合使用的良好库

[英]Good library for using TDD with MVC3

Building a new website at work and I'm trying to learn some TDD so that it can be implemented from the beginning on the new website (old site was plain asp pages with zero testing). 在工作中建立一个新网站,我正在尝试学习一些TDD,以便可以从一开始就在新网站上实施(旧网站是纯ASP页面,并进行了零测试)。 However, since I'm new to TDD I have no clue what some good libraries to use are. 但是,由于我是TDD的新手,所以我不知道要使用什么优秀的库。 I've already ran into issues trying to design tests... For example one of my controllers uses Server.MapPath() and consequently is currently failing. 我已经在尝试设计测试时遇到了问题……例如,我的一个控制器使用Server.MapPath() ,因此当前出现故障。 Trying to find a solid library that has been built well. 试图找到一个构建良好的可靠库。 I've googled and found an option or two, but have no clue what people that are already using TDD are using. 我已经在Google上搜索并找到了一个或两个选项,但不知道已经在使用TDD的人正在使用什么。 Since I have (want) to learn this I'd just assume learn it with a library that others are using with success. 因为我有(想要)学习这一点,所以我只是假设是通过一个他人成功使用的图书馆来学习它。

EDIT: Sorry I am currently using NUnit to do the tests in, but I'm open to other libraries 编辑:对不起,我目前正在使用NUnit进行测试,但是我对其他库开放

NUnit for automated testing, Moq / RhinoMocks for mocking/stubbing, Team City for continuous integration. NUnit用于自动化测试, Moq / RhinoMocks用于模拟/存根, Team City用于持续集成。 I personally prefer Moq, but you should give both of those a try. 我个人比较喜欢Moq,但是您应该尝试两者。

To deal with ASP.NET, there are some extensions for NUnit. 为了处理ASP.NET,NUnit有一些扩展。 For example, the one this guy describes . 例如, 此人描述的那个 There is already a question about NUnit and web applications here 这里已经有关于NUnit和Web应用程序的问题

您可能会发现此MSDN杂志文章 “使用SpecFlow和WatiN进行行为驱动的开发”很有趣。

NUnit with NUnit.Snippets Nuget package. NUnit与NUnit.Snippets Nuget包。

http://nuget.org/packages/NUnit.Snippets http://nuget.org/packages/NUnit.Snippets

In order to create testable application you will have to use Dependency Injection throughout whole code base or use some other patterns to be able to change implementations (for example the one you mentioned using Server.MapPath) during testing. 为了创建可测试的应用程序,您将必须在整个代码库中使用“依赖注入”,或者使用一些其他模式来更改测试过程中的实现(例如,您使用Server.MapPath提到的实现)。 To use DI you will need DI Container and your custom controller factory. 要使用DI,您将需要DI Container和您的自定义控制器工厂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM