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 ...
随机推荐
- CF528D Fuzzy Search 字符串匹配+FFT
题意: DNA序列,在母串s中匹配模式串t,对于s中每个位置i,只要s[i-k]到s[i+k]中有c就认为匹配了c.求有多少个位置匹配了t. 分析: 这个字符串匹配的方式,什么kmp,各种自动机都不灵 ...
- MySQL连接使用及分类
SQL连接 SQL 连接(JOIN)子句用于将数据库中两个或者两个以上表中的记录组合起来.连接通过共有值将不同表中的字段组合在一起. 考虑下面两个表,(a)CUSTOMERS 表:+----+---- ...
- windows环境下Robot Framework的安装步骤
Robot Framework是由python编写的开源的用来做功能性测试的自动化测试框架.本文介绍Robot Framework在windows环境下的安装步骤. 安装python从python官网 ...
- 关于flock文件锁的阻塞与非阻塞
阻塞模式,程序会一直等待. <?php $fp = fopen("lock.txt", "r"); if(flock($fp,LOCK_EX)) { // ...
- MySQL数据类型与操作
内容提要: 建表完整语法规范(create table 表格(字段名1 类型 (宽度) 约束条件)) MySQL数据库数据类型(整型.浮点型.字符类型(char与varchar).日期类型.枚举与集合 ...
- 前端基础之JavaScript_1
摘要: JavaScript简介 引入方式 语言规范 JavaScript语言基础 变量声明 数据类型 运算符 流程控制 函数 词法分析 内置对象 一.JavaScript概述 1.ECMAScrip ...
- The Coco-Cola Store
UVA11877 The Coco-Cola Store Once upon a time, there is a special coco-cola store. If you return thr ...
- rsync 同步文件重复拷贝问题
rsync 是同步文件的利器,一般用于多个机器之间的文件同步与备份,同时也支持在本地的不同目录之间互相同步文件.在这种场景下,rsync 远比 cp 命令更加合适,它只会同步需要更新的文件,默认情况下 ...
- list如何remove
http://blog.sina.com.cn/s/blog_621b6f0e0100s5n5.html 在java中对list进行操作很频繁,特别是进行list启遍历,这些操作我们都会,也很熟悉,但 ...
- python学习之 - re模块
re模块功能:实现字符串匹配. 元字符 描述\ 将下一个字符标记符.或一个向后引用.或一个八进制转义符.例如,“\\n”匹配\n.“\n”匹配换行符.序列“\\”匹配“\”而“\(”则匹配“(”.即相 ...