- 创建项目,选择.net core的类库(class library)
- 修改project.json的配置
{
"version": "1.0.0-*",
"testRunner": "xunit", "dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"xunit": "2.2.0-beta4-build3444",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"xunit.runners": "2.0.0"
}, "frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet54",
"portable-net45+win8"
]
}
} }
3.等包还原后,测试项目完成,可以开始写测试用例。
PS:使用xunit、dotnet-test-xunit和xunit.runners,以后有新版本时可以在配置后再使用nuget自行更新。visual studio的测试资源管理器可以正确发现所有有测试用例。
参考资料:https://docs.microsoft.com/en-us/dotnet/articles/core/testing/unit-testing-with-dotnet-test