1、NUnit

project.json

{
"version": "1.0.0-*",
"testRunner": "nunit",
"buildOptions": {
"debugType": "portable"
},
"dependencies": {
"NUnit": "3.5.0",
"dotnet-test-nunit": "3.4.0-beta-3"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "portable-net45+win8",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
}

测试类

using System;
using NUnit.Framework; namespace ClassLibrary
{
[TestFixture]
public class Class1
{
[Test]
public void Method1()
{
Assert.AreEqual(1101, 1100 + 1);
}
}
}

然后在集成终端里面输入dotnet test,就可以运行Console Runner

2、xunit

project.json

{
"version": "1.0.0-*",
"testRunner": "xunit",
"buildOptions": {
"debugType": "portable"
},
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
}

测试类

using System;
using Xunit; namespace ClassLibrary
{
public class Class1
{
public void Method1()
{ } [Fact]
public void PassingTest()
{
int a = 5;
int b = a;
Assert.Equal(b, Add(2, 2));
} [Fact]
public void FailingTest()
{
Assert.Equal(5, Add(2, 2));
} int Add(int x, int y)
{
return x + y;
}
}
}

和NUnit一样,输入dotnet test,就可以运行测试

Visual Studio Code现在也可以直接嗅探到测试方法,只需要在上面轻轻点击run test或者debug test就可以轻松的运行个别测试

Visual Studio Code Unit Testing的更多相关文章

  1. [转]Python in Visual Studio Code

    本文转自:https://code.visualstudio.com/docs/languages/python Working with Python in Visual Studio Code, ...

  2. [转] Visual Studio Code behind a proxy

    http://www.tuicool.com/articles/jyyIBf3 http://blog.majcica.com/2016/04/07/visual-studio-code-behind ...

  3. Scala on Visual Studio Code

    Download and install Scala Download a scala installation package from here. Then install it. Linux s ...

  4. 在Visual Studio Code中开发Office Add-in

    作者:陈希章 发表于 2017年7月13日 上一篇 我介绍了如何在Visual Studio中开发Office Add-in,因为有标准的项目模板,一系列配套的工具,尤其是自带的一键调试功能,可以让开 ...

  5. 开发者说 | 使用Visual Studio Code编译、调试Apollo项目

    转载地址:https://mp.weixin.qq.com/s?__biz=MzI1NjkxOTMyNQ==&mid=2247484266&idx=1&sn=d6bcd4842 ...

  6. [转]Using Angular in Visual Studio Code

    本文转自:https://code.visualstudio.com/docs/nodejs/angular-tutorial Using Angular in Visual Studio Code ...

  7. Java on Visual Studio Code的更新 – 2021年7月

    Nick zhu, Senior Program Manager, Developer Division at Microsoft 大家好,欢迎来到 7 月版的 Visual Studio Code ...

  8. Visual Studio Code 代理设置

    Visual Studio Code (简称 VS Code)是由微软研发的一款免费.开源的跨平台文本(代码)编辑器,在十多年的编程经历中,我使用过非常多的的代码编辑器(包括 IDE),例如 Fron ...

  9. 在Visual Studio Code中配置GO开发环境

    一.GO语言安装 详情查看:GO语言下载.安装.配置 二.GoLang插件介绍 对于Visual Studio Code开发工具,有一款优秀的GoLang插件,它的主页为:https://github ...

随机推荐

  1. 小而美的Promise库——promiz源码浅析

    背景 在上一篇博客[[译]前端基础知识储备--Promise/A+规范](https://segmentfault.com/a/11...,我们介绍了Promise/A+规范的具体条目.在本文中,我们 ...

  2. idea Error:(65, 27) java: 未结束的字符串文字

    今天在使用IDEA的时候,出现了这个错误,原因项目文件编码不一致导致的,解决方法是: 将项目的文件编码全改成一致(UTF-8),如下图所示:

  3. HTML5表单新增元素与属性

    form属性 在html4中,表单的从属元素必须写在表单内部,而在HTML5中,可以把他们书写在任何地方,然后为该元素指定一个form属性,属性值为该表单的id,这样就可以声明该元素从属于指定表单了. ...

  4. C#sql语句如何使用占位符

    背景:在程序中,写sql语句时,可能要根据变量的值不同,SQL语句产生相应的变化.比如说存在变量StuName,根据变量值的不同,检索不同姓名的学生记录,这时需用到占位符的知识. 1,{0}占位符,代 ...

  5. 大数据学习——flume拦截器

    flume 拦截器(interceptor)1.flume拦截器介绍拦截器是简单的插件式组件,设置在source和channel之间.source接收到的事件event,在写入channel之前,拦截 ...

  6. jenkins在linux环境搭建需要用到的linux命令

    需要用到的linux命令如下: 服务器jdk1.7/usr/java/jdk1.7.0_80 jdk1.8/home/hujb/javaJDK/jdk1.8.0_171保存文件时用 : w ! sud ...

  7. POJ-2590-Steps题目详解,思路分析及代码,规律题,重要的是找到规律~~

    Steps Time Limit: 1000MS   Memory Limit: 65536K       http://poj.org/problem?id=2590 Description One ...

  8. [NOIP1998] 提高组 洛谷P1013 进制位

    题目描述 著名科学家卢斯为了检查学生对进位制的理解,他给出了如下的一张加法表,表中的字母代表数字. 例如: L K V E L L K V E K K V E KL V V E KL KK E E K ...

  9. 汕头市赛srm10 T2

    n个数,分组,数Ai要在至少含有Ai个数的组,求最多分多少组. 方法一:大的数应该尽量跟大的在一起,这样才能让小的出现很多很多组,所以从大到小排序,给当前序列中最大的数x分x个数.代码如下: #inc ...

  10. excludepathpatterns 无效

    踩坑了,调了好久才调出来. 原因:  访问的API /XXX 已经转换为 /error 了.  把“/error” 也加入 excludepathpatterns 里面即可.