使用Xunit进行单元测试
2016-11-28 09:26
260 查看
http://xunit.github.io/docs/getting-started-desktop.html
1. 新建一个类库项目
2. 通过NuGet引入xunit,Shouldly,xunit.runner.visualstudio三个程序包。
3. 编写代码
4. 在测试方法上右键执行
——————————————————————
ps:测试管理资源器打开方式
附: VS插件
——————
.Net Core项目中使用 Xunit进行单元测试
.NET Core系列 :4 测试
版本兼容
1. 新建一个类库项目
2. 通过NuGet引入xunit,Shouldly,xunit.runner.visualstudio三个程序包。
3. 编写代码
public class Class1 { public int Add(int x, int y) { return x + y; } public string Reverse(string str) { return new string(str.Reverse().ToArray()); } }
public class Class1Tests { [Fact] public void AddTest() { var class1 = new Class1(); class1.Add(2, 2).ShouldBe(4); } [Fact] public void ReverseTest() { var class1 = new Class1(); class1.Reverse("hello").ShouldBe("olleh"); } [Fact] public void ReverseWithNull_Test() { var class1 = new Class1(); class1.Reverse(null).ShouldBe(null); } }
4. 在测试方法上右键执行
——————————————————————
ps:测试管理资源器打开方式
附: VS插件
——————
.Net Core项目中使用 Xunit进行单元测试
.NET Core系列 :4 测试
{ "version": "1.0.0-*", "testRunner": "xunit", "dependencies": { "xunit":"2.2.0-beta4-build3444", "Shouldly": "2.8.2", "xunit.runner.visualstudio": "2.2.0-beta4-build1194", "dotnet-test-xunit": "2.2.0-preview2-build1029" }, "frameworks": { "net452":{} } }
版本兼容
{ "version": "1.0.0-*", "testRunner": "xunit", "dependencies": { "NSubstitute": "2.0.3", "Shouldly": "2.8.3", "xunit": "2.2.0", "xunit.runner.visualstudio": "2.2.0" }, "runtimes": { "win10-x64": {} }, "frameworks": { "net46": { "dependencies": { "dotnet-test-xunit": "2.2.0-preview2-build1029" } }, "netcoreapp1.0": { "dependencies": { "Microsoft.NET.Test.Sdk": "15.0.0" } } } }
相关文章推荐
- 使用xUnit为.net core程序进行单元测试(3)
- 使用xUnit为.net core程序进行单元测试(2)
- ASP.NET Core中使用xUnit进行单元测试
- 使用xUnit为.net core程序进行单元测试(上)
- 使用xUnit为.net core程序进行单元测试(4)
- ASP.NET Core中使用xUnit进行单元测试
- VS2015 使用Xunit来进行单元测试
- 使用xUnit为.net core程序进行单元测试(1)
- 使用xUnit,EF,Effort和ABP进行单元测试(C#)
- 使用Xunit来进行单元测试
- 使用xUnit为.net core程序进行单元测试(4)
- 使用xUnit为.net core程序进行单元测试(中)
- 使用xUnit为.net core程序进行单元测试
- 使用xUnit为.net core程序进行单元测试(1)
- 使用Xunit来进行单元测试
- 使用NUnit进行单元测试,读配置文件的问题
- 使用NUnit在.Net编程中进行单元测试
- 使用 Visual Studio Team Test 进行单元测试
- 使用NUnit在.Net编程中进行单元测试
- 使用NUnit在.Net编程中进行单元测试