【发布时间】:2017-04-25 03:21:11
【问题描述】:
我刚刚将我的项目升级到 .Net Core 1.1,我的所有测试现在都没有被发现。在旧版本(.Net Core 1.0)中运行良好
以下是XUnit生成的VS 2015 Output Window中的消息
------ Discover test started ------
Discovering tests in 'C:\TW\websites2016\AssetsDB\src\Tests\project.json' ["C:\Program Files\dotnet\dotnet.exe" test "C:\TW\websites2016\AssetsDB\src\Tests\project.json" --output "C:\TW\websites2016\AssetsDB\src\Tests\bin\Debug\netcoreapp1.1" --port 61778 --parentProcessId 7316 --no-build]
'test-xunit' returned '-532462766'.
========== Discover test finished: 0 found (0:00:01.7697049) ==========
project.json 中的代码
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"AssetsDB": { "target": "project" },
"xunit": "2.2.0-beta4-build3444",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
}
}
我的样本测试:
namespace Tests
{
public class QueryPagingAssetsTest
{
[Fact]
public void should_return_PagingAssetItems()
{
Assert.True(xxxxx);
}
}
}
我有什么遗漏吗?我是否需要进行任何更改以使其与 .Net Core 1.1 兼容?
更新:project.json的工作版本
您需要添加 InternalAbstractions 库。如果您关注 Brad 的链接,它会告诉您使用“xunit.runner.visualstudio”而不是“xunit.runner.visualstudio”。但是 AFAIK,它还没有工作(截至 2016 年 9 月 12 日)
"dependencies": {
"AssetsDB": { "target": "project" },
"Microsoft.DotNet.InternalAbstractions": "1.0.1-beta-003206",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"xunit": "2.2.0-beta4-build3444",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
//"xunit.runner.visualstudio": "2.2.0-beta4-build1194"
},
【问题讨论】:
标签: c# asp.net-core xunit.net asp.net-core-1.1