什么是添加NUnit的测试,以现有的解决方案的接受的做法?

问题描述:

我继承了一个合理的规模ASP.net的解决方案,没有自动化测试。该解决方案似乎包括所有在一个解决方案,没有名字,间距和层没有分离源/页,所以有内隐藏文件code等。

I have inherited a reasonable sized ASP.net solution that has no automated tests. The solution seems to include all of the source/pages in one solution with no name-spacing and no separation of tiers, so there are direct SQL calls within code behind files etc.

在更改到这个网站,我想补充一些单元测试,pferably使用NUnit,因为我熟悉的xUnit模式$ P $,给我一些信心,我没有破坏任何东西。我没有太多的.NET经验,特别是我不知道何时使用项目VS解决方案等,虽然我很舒服与C#的基本语法等。

Before making changes to this site I would like to add some unit tests, preferably using nunit as I am familiar with the Xunit model, to give me some confidence that I have not broken anything. I do not have much .net experience, and particularly I am not sure about when to use projects vs solutions etc, although I am comfortable with the basic syntax etc of C#.

这是增加单元测试的溶液的推荐方法?我应该创建一个单独的解决方案/项目的测试,然后添加对现有解决方案的合适的元素,或者我应该创建一个单独的项目在现有解决方案中,以容纳测试套件。

What is the recommended method of adding units tests to a solution? Should I create a separate Solution/Project for the tests and then add references to appropriate elements of the existing solution, or should I create a separate project within the existing solution to house the test suite.

我真的找了这两种方法,或甚至另一种方法完全的利弊。什么是最好的方式人民的经验来做到这一点。

I am really looking for the pros and cons of both approaches, or indeed another method altogether. What are peoples experiences of the best way to achieve this.

我不知道,你可以使用单元测试开始。记住,第一条规则是不要打破什么工作,我会建议开始使用类似华廷或硒一些集成和回归测试。这两个框架可以运行单元测试框架,如NUnit的集成测试。做的Telerik之一,也是,但它不是免费的,我还没有使用过。

I'm not sure you can start with Unit tests. Remembering that the first rule is "Don't break what works", I would suggest starting with some integration or regression tests using something like WatiN or Selenium. Both of these frameworks can run the integration tests from unit test frameworks such as NUnit. Telerik do one as well but it's not free and I haven't used it.

一旦你有在地方,你可以开始移动code到层,你没有突破网站的知识的过程。然后,这是一个很好的时间来介绍单元测试。

Once you have that in place, you can start the process of moving code into layers with the knowledge that you're not breaking the website. This is then a good time to introduce unit tests.

这我会通过让一个项目,里面所有的单元测试,以引用包含要测试的类的项目做。我相信,这也是很好的做法,你的层次分成的项目。

This I would do by having one project that houses all of the unit tests, with references to the projects that contain the classes you are testing. I believe it's also good practice to separate your tiers into projects.