简体   繁体   English

C#中的JUnit等效于什么?

[英]What is the equivalent to JUnit in C#?

I am coming from Java and am currently working on a C# project. 我来自Java,目前正在从事C#项目。 What is the recommended way to go about a) unit testing existing C# code and b) accomplishing TDD for C# development? 建议的方法是:a)对现有C#代码进行单元测试,以及b)为C#开发完成TDD?

Also is there an equivalent to EMMA / EclEmma (free yet powerful code coverage tool) for Visual Studio and C# code? 还有针对Visual Studio和C#代码的等效于EMMA / EclEmma(免费但功能强大的代码覆盖工具)吗?

1 Nunit 1 NUnit的
2 NCover or 2 NCover
3 PartCover (I never used it) 3 PartCover (我从未使用过)

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

Unit test framework: NUnit 单元测试框架: NUnit

Unit test runner: Various, but personally I like the one in ReSharper . 单元测试运行器:多种多样,但是我个人喜欢ReSharper中的那种 (ReSharper costs money, but is easily worth it for the various productivity improvements.) (ReSharper会花钱,但是对于各种生产力的提高来说很值得。)

Coverage: NCover (I think this used to be free, but it now costs money. Hmm.) 报道: NCover (我认为以前是免费的,但现在要花钱。嗯。)

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

Regarding your question about unit test frameworks: 关于您有关单元测试框架的问题:

NUnit 1.0 was a direct port of JUnit. NUnit 1.0是JUnit的直接端口。 NUnit 2.0 moved away from JUnit syntax in order to take advantage of the .NET platform. 为了利用.NET平台,NUnit 2.0放弃了JUnit语法。 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." xUnit.net是一个较新的单元测试框架(来自NUnit 2.0开发人员之一的Jim Newkirk和Brad Wilson)指出,其目标是暴露“在.NET中尚未真正浮出水面的其他单元测试库实现的先进性”,我读为“跟上JUnit的步伐”。

NUnit就是这样。

NUnit, but NCover is only part of the answer as it isn't free. NUnit,但NCover并不是解决方案的一部分,因为它不是免费的。 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 适用于您的单元测试框架的NUnit http://www.nunit.org/index.php
  2. Test driven.net for runing your tests http://www.testdriven.net/ 用于运行测试的Testdriven.net http://www.testdriven.net/
  3. Rhino Mocks as your mockign framework http://ayende.com/projects/rhino-mocks.aspx Rhino Mocks作为您的模仿框架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... 顺便说一句,我感到奇怪的是,NUnit的家伙似乎正在使用php来托管他们的主页...

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

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