运行 在 Visual Studio Team Services 中部署后的集成测试
Run integration tests after deployment in Visual Studio Team Services
我在 Visual Studio Team Services 中添加了一个发布定义,用于将应用程序部署到 Azure 云服务。成功部署后,我正在尝试 运行 一些集成测试:
但不幸的是测试不是 运行:
Warning: No test is available in C:\a1532a74\Build\Api.Web.IntegrationTests\Api.Web.IntegrationTests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
##[warning]No results found to publish.
我已经为所有包含测试(单元测试和集成测试)的项目安装了 NUnit 测试适配器(nuget 包)。奇怪的是,我能够 运行 测试作为 build 的一部分,但不能作为 release 的一部分。
我也尝试将路径设置为自定义测试适配器,但它似乎没有什么不同。
我在这里缺少什么?有没有更好的方法 运行 一些集成测试作为发布的一部分?
这通常是由于 VSTest 找不到 NUnit 测试适配器造成的。
通常,在"Build" 环境中,NUnit 测试适配器由nuget 恢复到工作文件夹中,因此VSTest 可以在测试过程中找到它。但在 "Release" 环境下,NUnit 测试适配器默认不存在。因此,您需要更新构建定义以将 NUnit 测试适配器文件上传到 "drop",并且在下载工件后 NUnit 测试适配器将在 "Release" 环境中可用。然后你可以将 "Path to Custom Test Adapters" 设置为 "$(System.DefaultWorkingDirectory)\" 然后再试一次。
如果您使用自己的构建代理,您还可以将 NUnit 测试适配器放在构建代理可以访问的永久路径中,并为其设置 "Path to Custom Test Adapters"。或者在构建代理上安装 VS 的 NUnit 测试适配器扩展并在 "Visual Studio Test\Other console options".
中输入“/UseVsixExtensions:true”
根据 Eddie 的建议,我找到了解决问题的方法:
第 1 步 - 将所有 NUnit 程序集复制到测试项目的输出文件夹(将 Copy Local 属性 设置为 True)
第 2 步 - 创建一个包含测试项目 bin 文件夹中所有文件的工件。这不仅包含测试程序集,还包含 NUnit 程序集
步骤 3 - 在测试任务中,将自定义测试适配器的路径设置为包含测试程序集和 NUnit 适配器程序集的工件文件夹
就是这样!下次您创建发布并部署到任何环境时,将执行测试。
我的问题是我根本没有安装 NUnit 的测试运行器,因为我使用的是 resharpers 测试运行器。
因此,我的解决方案就像将 nuget 包 "NUnit3TestAdapter" version="3.4.0" 添加到我的测试项目一样简单。
在 visualstudio.com(VS 在线)"Nuget restored adapters are automatically searched for." 并且您需要 not/should 而不是为 "Custom Test Adapters" 指定路径
- 我不知道这是否也适用于 NUnit 测试适配器版本 2。
我在 Visual Studio Team Services 中添加了一个发布定义,用于将应用程序部署到 Azure 云服务。成功部署后,我正在尝试 运行 一些集成测试:
但不幸的是测试不是 运行:
Warning: No test is available in C:\a1532a74\Build\Api.Web.IntegrationTests\Api.Web.IntegrationTests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
##[warning]No results found to publish.
我已经为所有包含测试(单元测试和集成测试)的项目安装了 NUnit 测试适配器(nuget 包)。奇怪的是,我能够 运行 测试作为 build 的一部分,但不能作为 release 的一部分。
我也尝试将路径设置为自定义测试适配器,但它似乎没有什么不同。
我在这里缺少什么?有没有更好的方法 运行 一些集成测试作为发布的一部分?
这通常是由于 VSTest 找不到 NUnit 测试适配器造成的。
通常,在"Build" 环境中,NUnit 测试适配器由nuget 恢复到工作文件夹中,因此VSTest 可以在测试过程中找到它。但在 "Release" 环境下,NUnit 测试适配器默认不存在。因此,您需要更新构建定义以将 NUnit 测试适配器文件上传到 "drop",并且在下载工件后 NUnit 测试适配器将在 "Release" 环境中可用。然后你可以将 "Path to Custom Test Adapters" 设置为 "$(System.DefaultWorkingDirectory)\" 然后再试一次。
如果您使用自己的构建代理,您还可以将 NUnit 测试适配器放在构建代理可以访问的永久路径中,并为其设置 "Path to Custom Test Adapters"。或者在构建代理上安装 VS 的 NUnit 测试适配器扩展并在 "Visual Studio Test\Other console options".
中输入“/UseVsixExtensions:true”根据 Eddie 的建议,我找到了解决问题的方法:
第 1 步 - 将所有 NUnit 程序集复制到测试项目的输出文件夹(将 Copy Local 属性 设置为 True)
第 2 步 - 创建一个包含测试项目 bin 文件夹中所有文件的工件。这不仅包含测试程序集,还包含 NUnit 程序集
步骤 3 - 在测试任务中,将自定义测试适配器的路径设置为包含测试程序集和 NUnit 适配器程序集的工件文件夹
就是这样!下次您创建发布并部署到任何环境时,将执行测试。
我的问题是我根本没有安装 NUnit 的测试运行器,因为我使用的是 resharpers 测试运行器。
因此,我的解决方案就像将 nuget 包 "NUnit3TestAdapter" version="3.4.0" 添加到我的测试项目一样简单。
在 visualstudio.com(VS 在线)"Nuget restored adapters are automatically searched for." 并且您需要 not/should 而不是为 "Custom Test Adapters" 指定路径 - 我不知道这是否也适用于 NUnit 测试适配器版本 2。