当 Teamcity 运行启动自托管 Web 应用程序的集成测试时,测试失败并显示错误:
System.MissingMemberException: The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener
抛出此错误的代码是:
var webApp = WebApp.Start<Startup>("http://*:52203/")
使用 Visual Studio(使用 Resharper 测试运行器)执行时,测试运行良好。 Teamcity 配置为使用JetBrains.BuildServer.NUnitLauncher.exe
可执行文件来运行测试。
我看到很多关于此错误的帖子都与此有关,因为Microsoft.Owin.Host.HttpListener.dll
不存在于 bin\debug 或 bin\release 文件夹中。我可以确认该文件(以及随附的 .xml 文件)都存在于 TeamCity buildAgent 使用的 bin\release 文件夹中。不存在 bin\debug 文件夹。
我在 Powershell 脚本中遇到了这种情况,该脚本迭代我们的所有解决方案并使用 MSBuild 构建它们,然后在所有测试项目上调用 MSTest。该脚本用于在提交到 TFS 之前在本地构建和测试所有解决方案。在 VS 中运行测试时不会出现此问题。我相信这与这个问题 https://stackoverflow.com/questions/1132243/msbuild-doesnt-copy-references-dlls-if-using-project-dependencies-in-solution.
在测试初始化中调用 WebApp.Start("http://*:52203/") 之前放置以下内容。
// This uber silly code is needed to ensure the Owin HttpListener assembly
// is properly copied to the output directory by using it, utterly redonkulous.
var uberSillyNecessity = typeof(OwinHttpListener);
if (uberSillyNecessity != null) { }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)