请注意,我是相当新的C#以及测试。
我的测试没有出现在测试资源管理器中。我正在使用visual 2015更新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": {}
}
}当我单击测试资源管理器中的run按钮(它应该找到我的所有测试)时,我将得到以下输出:
Discovering tests in 'C:\Users\daniel\Repos\earthworm\test\earthworm.test\project.json' 然后在测试浏览器中什么也没有出现。我已经尝试过查看使用.NET 3测试NUnit内核,所以如果您使用的是最新的框架,这是可能的。我只想知道如何用dnx451来完成这个任务。
发布于 2016-08-10 13:33:12
您缺少了对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": {}
}
}发布于 2018-01-27 15:51:28
如果上述任何一项都不适用于您:
如果您在发现或运行测试时遇到问题,则可能是Visual中已损坏的运行程序缓存的牺牲品。若要清除此缓存,请关闭Visual的所有实例,然后删除文件夹%TEMP%\VisualStudioTestExplorerExtensions扩展。还要确保您的解决方案仅与Visual包(xunit.runner.visualstudio)的单个版本链接。
来自:http://xunit.github.io/docs/getting-started-dotnet-core.html
https://stackoverflow.com/questions/38874535
复制相似问题