Fork me on GitHub

【记录】xUnit for vs2012/vs2013

  关于 NUint 以及单元测试的相关内容,可以参考:【单元测试】NUint使用详解及Visual Studio配置

  xUnit 是 NUint 的进化版本,使用方法和 NUint 类似,首先下载安装一个“xUnit.net runner for Visual Studio 2012 and 2013”,下载地址:http://visualstudiogallery.msdn.microsoft.com/463c5987-f82b-46c8-a97e-b1cde42b9099,然后使用 NuGet 命令添加引用包:install-package xunit

  测试示例代码:

复制代码
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using Xunit;
 6 
 7 namespace DemoTests
 8 {
 9     public class Test
10     {
11         [Fact]
12         public void TestMethod()
13         {
14             Assert.Equal("1", "1");
15         }
16     }
17 }
复制代码

  xUnit 的使用很简单,不像 NUint 需要在测试类前加 TestFixture 标记,而只需要在测试方法前加 Fact 标记就可以了,其他的使用方法(比如断言)和 NUint比较类似。

  关于 xUnit 在 vs2012/vs2013 中的使用,只需要安装“NUnit Test Adapter”即可,使用方法和 NUint 类似,“NUnit Test Adapter”目前支持以下测试框架:

  • NUnit
  • xUnit.net
  • MbUnit
  • QUnit
  • Jasmine

  “NUnit Test Adapter”的安装使用,可以参照:http://www.cnblogs.com/xishuai/p/3728576.html#xishuai_h4_3

  在生成解决方案后,会自动检测解决方案中所包含的测试用例:

  vs2013 需要安装:https://xunit.codeplex.com/releases

  就记录到这里。

posted @   田园里的蟋蟀  阅读(3026)  评论(8编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示