在c#中配置xunit单元测试

 1,直接使用NuGet安装如下两个库

xunit

xunit.runner.visualstudio -Pre

如果报:“xunit.core”已拥有为“xunit.extensibility.core”定义的依赖项。


安装xunit.net 的问题

Attempting to resolve dependency 'xunit'. Attempting to resolve dependency 'xunit.core (= 2.0.0-rc1-build2826)'. 'xunit.core' already has a dependency defined for 'xunit.extensibility.core'.”,原因是nuget的版本需要update。

具体的做法:

Tools > Extensions and Updates > Updates > Visual Studio Gallery 下update NuGet itself

然后安装xunit.runner​, VS就会检查到用户的test



2,调出2012的测试资源管理器

测试-》窗口-》测试资源管理器

3,书写代码:

namespace chsarpsdk.Qiniu.Test.Http
{
  
   public class httptest1
    {
        [Fact]
        public void TestAdd()
        {
            Assert.Equal<int>(5, 2 + 1);
            Console.WriteLine("woaini");
        }
        [Fact]
        public void testMax()
        {
            Assert.Equal(3, Math.Max(3, 2));
        } 


    }
}

其中一个成功,一个失败

4,测试结果:

http://liuhanlin-work.qiniudn.com/F%25@7H})EVYZDV]HVM}8C~D1.png



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值