使用 Asp.Net 核心和 Nunit 的测试未在 TestExplorer 中显示
Tests not showing in TestExplorer using Asp.Net core and Nunit
请注意,我对 C# 和测试都很陌生。
我的测试没有出现在测试资源管理器中。我正在使用 visual studio 2015 update 3 以及新的 asp.net 核心项目结构。
我的 project.json 文件如下所示:
{
"version": "1.0.0-*",
"description": "Tests for the earthworm",
"dependencies": {
"earthworm": "1.0.0-*",
"NSubstitute": "2.0.0-rc",
"NUnit.Runners": "3.4.1",
"NUnit3TestAdapter": "3.4.1",
"NUnitLite": "3.4.1",
"NUnit.Console": "3.4.1",
"Microsoft.Dnx.TestHost": "1.0.0-rc1-final",
"Microsoft.Dnx.Runtime": "1.0.0-rc1-final"
},
"testRunner": "nunit",
"commands": {
"Test": "earthworm.test"
},
"frameworks": {
"dnx451": {}
}
}
当我单击测试资源管理器中的 运行 全部按钮时,它应该会找到我的所有测试,我得到以下输出:
Discovering tests in 'C:\Users\daniel\Repos\earthworm\test\earthworm.test\project.json'
然后测试资源管理器中没有显示任何内容。
我已经尝试查看 Testing .NET Core using NUnit 3 所以看起来如果您使用的是最新的框架是可能的。我只是想知道 dnx451 如何完成这个。
您缺少对 dotnet-test-nunit
和 NUnit
的依赖,并且有许多不需要的引用。我真的很惊讶您能够使用该依赖项列表编写单元测试,但我猜 NUnit 会被 NUnitLite 引入。
从这样的project.json开始,
{
"version": "1.0.0-*",
"description": "Tests for the earthworm",
"dependencies": {
"earthworm": "1.0.0-*",
"NSubstitute": "2.0.0-rc",
"NUnit": "3.4.1",
"dotnet-test-nunit": "3.4.0-beta-2"
},
"testRunner": "nunit",
"frameworks": {
"dnx451": {}
}
}
如果以上 none 适合您:
If you're having problems discovering or running tests, you may be a victim of a corrupted runner cache inside Visual Studio. To clear this cache, shut down all instances of Visual Studio, then delete the folder %TEMP%\VisualStudioTestExplorerExtensions. Also make sure your solution is only linked against a single version of the Visual Studio runner NuGet package (xunit.runner.visualstudio).
发件人:http://xunit.github.io/docs/getting-started-dotnet-core.html
请注意,我对 C# 和测试都很陌生。
我的测试没有出现在测试资源管理器中。我正在使用 visual studio 2015 update 3 以及新的 asp.net 核心项目结构。
我的 project.json 文件如下所示:
{
"version": "1.0.0-*",
"description": "Tests for the earthworm",
"dependencies": {
"earthworm": "1.0.0-*",
"NSubstitute": "2.0.0-rc",
"NUnit.Runners": "3.4.1",
"NUnit3TestAdapter": "3.4.1",
"NUnitLite": "3.4.1",
"NUnit.Console": "3.4.1",
"Microsoft.Dnx.TestHost": "1.0.0-rc1-final",
"Microsoft.Dnx.Runtime": "1.0.0-rc1-final"
},
"testRunner": "nunit",
"commands": {
"Test": "earthworm.test"
},
"frameworks": {
"dnx451": {}
}
}
当我单击测试资源管理器中的 运行 全部按钮时,它应该会找到我的所有测试,我得到以下输出:
Discovering tests in 'C:\Users\daniel\Repos\earthworm\test\earthworm.test\project.json'
然后测试资源管理器中没有显示任何内容。 我已经尝试查看 Testing .NET Core using NUnit 3 所以看起来如果您使用的是最新的框架是可能的。我只是想知道 dnx451 如何完成这个。
您缺少对 dotnet-test-nunit
和 NUnit
的依赖,并且有许多不需要的引用。我真的很惊讶您能够使用该依赖项列表编写单元测试,但我猜 NUnit 会被 NUnitLite 引入。
从这样的project.json开始,
{
"version": "1.0.0-*",
"description": "Tests for the earthworm",
"dependencies": {
"earthworm": "1.0.0-*",
"NSubstitute": "2.0.0-rc",
"NUnit": "3.4.1",
"dotnet-test-nunit": "3.4.0-beta-2"
},
"testRunner": "nunit",
"frameworks": {
"dnx451": {}
}
}
如果以上 none 适合您:
If you're having problems discovering or running tests, you may be a victim of a corrupted runner cache inside Visual Studio. To clear this cache, shut down all instances of Visual Studio, then delete the folder %TEMP%\VisualStudioTestExplorerExtensions. Also make sure your solution is only linked against a single version of the Visual Studio runner NuGet package (xunit.runner.visualstudio).
发件人:http://xunit.github.io/docs/getting-started-dotnet-core.html