简体   繁体   中英

What is the equivalent to JUnit in C#?

I am coming from Java and am currently working on a C# project. What is the recommended way to go about a) unit testing existing C# code and b) accomplishing TDD for C# development?

Also is there an equivalent to EMMA / EclEmma (free yet powerful code coverage tool) for Visual Studio and C# code?

1 Nunit
2 NCover or
3 PartCover (I never used it)

NUnit是在JUnit之后进行模式化的,但是如果您使用的是Visual Studio 2008,请考虑使用内置的单元测试框架。

Unit test framework: NUnit

Unit test runner: Various, but personally I like the one in ReSharper . (ReSharper costs money, but is easily worth it for the various productivity improvements.)

Coverage: NCover (I think this used to be free, but it now costs money. Hmm.)

我强烈建议Gallio (以前是mbUnit)进行单元测试,(不幸的是不是免费的)建议使用NCover进行代码覆盖。

Regarding your question about unit test frameworks:

NUnit 1.0 was a direct port of JUnit. NUnit 2.0 moved away from JUnit syntax in order to take advantage of the .NET platform. xUnit.net is a newer unit test framework (from Jim Newkirk - one of the NUnit 2.0 developers - and Brad Wilson) that states as a goal exposing "advances in other unit test library implementations that have not really surfaced in .NET," which I read as "keeping up with JUnit."

NUnit就是这样。

NUnit, but NCover is only part of the answer as it isn't free. I've asked elsewhere about that.

VS2008 Professional具有团队系统单元测试功能。

NUnit的肯定。

I'd install:

  1. NUnit for your Unit testing framework http://www.nunit.org/index.php
  2. Test driven.net for runing your tests http://www.testdriven.net/
  3. Rhino Mocks as your mockign framework http://ayende.com/projects/rhino-mocks.aspx

As and aside I find it odd that the NUnit guys seem to be using php to host their homepage...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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