一、NUnitjavascript
project.jsonjava
{ "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" } } } } }
测试类json
using System; using NUnit.Framework; namespace ClassLibrary { [TestFixture] public class Class1 { [Test] public void Method1() { Assert.AreEqual(1101, 1100 + 1); } } }
而后在集成终端里面输入dotnet test,就能够运行Console Runnerapp
二、xunit测试
project.jsonui
{ "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" } } } } }
测试类spa
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,就能够运行测试debug
Visual Studio Code如今也能够直接嗅探到测试方法,只须要在上面轻轻点击run test或者debug test就能够轻松的运行个别测试orm