C#整合VS2010和NUnit
软件下载
.Net单元测试工具 NUnit下载:http://www.nunit.org/index.php?p=download,最新的为NUnit-2.6.0.12051.msi,下载安装。
VS2010 NUnit 整合插件 Visual Nunit 2010下载:http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099,下载安装完毕就能在 VS2010 的 view->Other Windows中看到 Visual Nunit了(或使用快捷键Ctrl + F7),打开该视图,将之拖到合适的位置。
测试程序
1,新建名为 NUnitSample 的C#控制台应用程序。在References中增加References:nunit.framework,路径默认为:C:\Program Files \NUnit 2.6\bin\framework\nunit.framewor.dll。
2,删除 Class1.cs,增加两个C#文件:NUnitSample.cs 和NUnitSampleTest.cs。其内容分别为:
// File: NUnitSample.cs
//
using System; namespace NUnitSample
{
public class MathUtil
{
public int Add(int a, int b)
{
return a + b;
} static void Main(string[] args)
{
}
}
}
和
// File: NUnitSampleTest.cs
//
using System;
using NUnit.Framework; namespace NUnitSample
{
[TestFixture]
public class NUnitSampleTest
{
[Test]
public void AddTest()
{
MathUtil util = new MathUtil();
int result = util.Add(4, 4);
Assert.AreEqual(8, result);
} [Test]
public void AddTestFailure()
{
MathUtil util = new MathUtil();
int result = util.Add(4, 4);
Assert.AreEqual(6, result);
}
}
}
在上面的代码中引用 NUnit.Framework,使用[TestFixture]表明这是用于测试的类,在其中使用 [Test]表示具体的测试用例,在这里添加了两个测试用例:一个成功的和一个失败的测试。
3,编译,然后点击 Visula Unit中的 Run 按钮就能运行测试用例了。从下图可以看到失败的测试用例显示的比较详细的信息。

C#整合VS2010和NUnit的更多相关文章
- 转:VS2010调试NUnit测试项目 (Running or debugging NUnit tests from Visual Studio without any extensions)
If you write unit tests and use NUnit test framework this may be helpful. I decided to write this si ...
- Nunit工具做C#的单元测试
Nunit工具做C#的单元测试 学习心得 编写人:罗旭成 时间:2013年9月2日星期一 1.开发人员如何做单元测试 单元测试是针对最小的可测试软件元素(单元)的,它所测试的内容包括单元的内部结构 ...
- NUnit单元测试资料汇总
NUnit单元测试资料汇总 从安装到配置 首先到官网http://www.nunit.org/下载如下图的资料,安装NUnit-2.6.1.msi包. 然后挂在VS2010外部工具这个地方来使用,工具 ...
- NUnit单元测试笔记
vs2010 和 NUnit 问题处理. . 在 <configuration> 下 加 ... <startup> <requiredRuntime version=& ...
- 实现VS2010整合NUnit进行单元测试(转载)
代码编写,单元测试必不可少,简单谈谈Nunit进行单元测试的使用方式: 1.下载安装NUnit(最新win版本为NUnit-2.6.4.msi) http://www.nunit.org/index. ...
- 5分钟实现VS2010整合NUnit进行单元测试
本文转载自:http://www.cnblogs.com/jeffwongishandsome/archive/2012/03/18/2404845.html 1.下载安装NUnit(最新win版本为 ...
- 实现VS2010整合NUnit进行单元测试
1.下载安装NUnit(最新win版本为NUnit.3.2.1.msi) http://www.nunit.org/index.php?p=download 2.下载并安装VS的Visual Nuni ...
- VS2010整合NUnit进行单元测试
1.下载安装NUnit(最新win版本为NUnit-2.6.0.12051.msi) http://www.nunit.org/index.php?p=download 2.下载并安装VS的Visua ...
- [转] VS 整合NUnit进行单元测试
Jeff Wong原文 5分钟实现VS2010整合NUnit进行单元测试 1.下载安装NUnit(最新win版本为NUnit-2.6.0.12051.msi) http://www.nunit.org ...
随机推荐
- 大数据学习资料之SQL与NOSQL数据库
这几年的大数据热潮带动了一激活了一大批hadoop学习爱好者.有自学hadoop的,有报名培训班学习的.所有接触过hadoop的人都知道,单独搭建hadoop里每个组建都需要运行环境.修改配置文件测试 ...
- 【ActiveMQ入门-9】ActiveMQ学习-与Spring集成2
概述: 下面将介绍如何在Spring下集成ActiveMQ. 消费者:同步接收: 目的地:Queue 环境: 共5个文件 Receiver.java ReceiverTest.java Sender. ...
- xml dom minidom
一. xml相关术语: 1.Document(文档): 对应一个xml文件 2.Declaration(声明): <?xml version="1.0" encoding=& ...
- sublime快捷键功能记录
shift+tab 向前缩进 ctrl+shift+k 删除当前行 菜单栏 view--side bar 选项 控制左侧文件展示视图 菜单栏“view”——“hideMiniMap” or &qu ...
- VBA文本型数字变成数值
sub test()with activesheet .usedrange.numberformatlocal="" .usedrange=.usedrange.valueen ...
- Koa 框架整理
学习交流 Koa使用了ES6规范的generator和异步编程是一个更轻量级Web开发的框架,Koa 的先天优势在于 generator.由于是我个人的分享交流,所以Node基础.ES6标准.Web开 ...
- Session的使用与Session的生命周期
1.HttpSession的方法 Object getAttribute(String); Enumeration<String> getAttributeNames(); long ge ...
- 基于标准库实现string和wstring的转换
// convert string to wstring std::wstring to_wstring(const std::string& str, const std::locale&a ...
- Python:23种Pandas核心操作
Pandas 是一个 Python 软件库,它提供了大量能使我们快速便捷地处理数据的函数和方法.一般而言,Pandas 是使 Python 成为强大而高效的数据分析环境的重要因素之一.在本文中,作者从 ...
- https://127.0.0.1:8080/test?param={%22..报错
使用场景:spring boot 1.5.x,内置的tomcat版本为8.5.1 原因: tomcat自tomcat 8.0.35版本之后对URL参数做了比较规范的限制,必须遵循RFC 7230 an ...