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

  就记录到这里。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值