Visual Studio Code Unit Testing
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的更多相关文章
- [转]Python in Visual Studio Code
本文转自:https://code.visualstudio.com/docs/languages/python Working with Python in Visual Studio Code, ...
- [转] Visual Studio Code behind a proxy
http://www.tuicool.com/articles/jyyIBf3 http://blog.majcica.com/2016/04/07/visual-studio-code-behind ...
- Scala on Visual Studio Code
Download and install Scala Download a scala installation package from here. Then install it. Linux s ...
- 在Visual Studio Code中开发Office Add-in
作者:陈希章 发表于 2017年7月13日 上一篇 我介绍了如何在Visual Studio中开发Office Add-in,因为有标准的项目模板,一系列配套的工具,尤其是自带的一键调试功能,可以让开 ...
- 开发者说 | 使用Visual Studio Code编译、调试Apollo项目
转载地址:https://mp.weixin.qq.com/s?__biz=MzI1NjkxOTMyNQ==&mid=2247484266&idx=1&sn=d6bcd4842 ...
- [转]Using Angular in Visual Studio Code
本文转自:https://code.visualstudio.com/docs/nodejs/angular-tutorial Using Angular in Visual Studio Code ...
- Java on Visual Studio Code的更新 – 2021年7月
Nick zhu, Senior Program Manager, Developer Division at Microsoft 大家好,欢迎来到 7 月版的 Visual Studio Code ...
- Visual Studio Code 代理设置
Visual Studio Code (简称 VS Code)是由微软研发的一款免费.开源的跨平台文本(代码)编辑器,在十多年的编程经历中,我使用过非常多的的代码编辑器(包括 IDE),例如 Fron ...
- 在Visual Studio Code中配置GO开发环境
一.GO语言安装 详情查看:GO语言下载.安装.配置 二.GoLang插件介绍 对于Visual Studio Code开发工具,有一款优秀的GoLang插件,它的主页为:https://github ...
随机推荐
- int (*a)[10]和int *a[10]的区别
有点晚了,放个链接,睡觉. https://stackoverflow.com/questions/13910749/difference-between-ptr10-and-ptr10
- [CF] 402 E. Strictly Positive Matrix
一个矩阵,自乘无限次后能否全为正数? 如果n比较小,可以二分一下,但是这里n很大,乘一次都无法接受 可以考虑实际含义:矩阵看成邻接矩阵,那么0就是没有边,其余就是有边. 我们知道邻接矩阵自乘k次就相当 ...
- php微信公众号开发之快递查询
[文章来源:脚本之家 文章地址:https://www.jb51.net/article/149205.htm] 本文实例为大家分享了php微信公众号开发之快递查询的具体代码,供大家参考,具体内容 ...
- Java Web中的编码解析
在springmvc工程web.xml中配置中文编码 <!-- 配置请求过滤器,编码格式设为UTF-8,避免中文乱码--> <filter> <filter-name&g ...
- Python面向对象之异常
异常的概念 程序在运行时,如果python解释器遇见一个错误,就会停止程序的运行,并且提示一些错误信息,这就是异常: 程序遇见错误停止执行并且提示错误信息,这个动作我们称之为抛出(raise)异常: ...
- C语言学习12
希尔排序 //希尔排序 #include <stdio.h> void main() { ], i; int shell(int a[], int n); printf("请输入 ...
- 剑指Offer(书):重建二叉树
题目:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字.例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2, ...
- 算法导论 第十章 基本数据类型 & 第十一章 散列表(python)
更多的理论细节可以用<数据结构>严蔚敏 看几遍,数据结构很重要是实现算法的很大一部分 下面主要谈谈python怎么实现 10.1 栈和队列 栈:后进先出LIFO 队列:先进先出FIFO p ...
- 简单的MVC 权限管理
花了3天时间研究了下对于 NHibernate+MVC4+bootstrap+Redis(这个是选配只做了登陆测试)+T4 这些都是第一次使用.用着有些生硬权当鼓励下自己,记录下来有空就继续完善. 思 ...
- SpringCloud源码地址
SpringCloud实战源代码 https://github.com/springcloud/spring-cloud-code.git