我正在构建一个在CLR 4.6.1上运行的ASP .NET Core项目。它使用传统的CLR 4.6.1库,这是一个巨大的问题。因为.NET Core VS工具无法正确构建项目,所以我不得不编写修复它的构建脚本 - 结果是VS无法构建项目的工作版本。
考虑到这一点,我该如何对此进行单元测试?理想情况下,我想要一个可以加载预编译项目的独立测试运行器,以避免测试工具必须构建我的主项目。
我已经尝试了两个MSTest(它看不到对SUT的引用)和Xunit使用dotnet test
(试图构建项目)。
根据要求,我(略有消毒)project.json
:
{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"System.Configuration.Abstractions": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net461": {
"dependencies": {
"MyLib.Common": {
"target": "project"
},
"MyLib.Integration": {
"target": "project"
},
"MyLib.Functions": {
"target": "project"
},
"MyLib.Numbers": {
"target": "project"
}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
答案 0 :(得分:2)
由于声誉我无法提交评论,您是否尝试过NUnit Test Runner?它作为一个独立的控制台应用程序,并将编译的测试DLL名称作为参数。