51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2146|回复: 0
打印 上一主题 下一主题

[转贴] 在c#中配置xunit单元测试

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-4-12 16:23:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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));
        }


    }
}

其中一个成功,一个失败


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-4-26 10:45 , Processed in 0.066531 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表