【问题标题】:"Run Functional Tests" task and Specflow - App.config being ignored?“运行功能测试”任务和 Specflow - App.config 被忽略?
【发布时间】:2017-01-03 15:37:05
【问题描述】:

我在 TFS 2015 更新 2 中创建了一个发布定义,如下所示:

我想将其用作我的 CI 流程的一部分。每次签入的构建和单元测试都在专用的 BizTalk 构建服务器上执行。每晚执行一次,这个(当前有问题的)版本应该部署到“DevTest”BizTalk 服务器并执行集成测试。

一切顺利,直到最后一个“运行功能测试”任务。因此,BizTalk 应用程序被删除,然后以正确的顺序部署到目标服务器。 “IntegrationTests”程序集包含一些使用 Transmock 框架 (http://transmock.codeplex.com/) 的 Specflow 测试。这些测试的步骤包含在一个名为“Common.Components”的程序集中。这是从名为“Finance.IntegrationTests.dll”的测试程序集引用的。在我的 Dev VM 上运行时测试通过。但是,当由“运行功能测试”任务执行时,我收到以下错误:

测试方法 Finance.IntegrationTests.ASC_BacsFeature.BacsFileMoved 抛出异常:NUnit.Framework.InconclusiveException:没有为一个或多个步骤找到匹配的步骤定义。使用 System;using TechTalk.SpecFlow;namespace MyNamespace{ [Binding] public class StepDefinitions { [Given(@"由 sso app '(.)' 和设置 '(.)' 指定的输出路径")]public void GivenAnOutputPathSpecifiedBySsoAppAndSetting(string p0, string p1){ ScenarioContext.Current.Pending ();} [Given(@"输入

我已将我的测试项目的 App.config 设置为使用 MsTest,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>
  <specFlow>
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
    <unitTestProvider name="MsTest"/>
    <stepAssemblies>
       <stepAssembly assembly="LCC.Integration.Common.Components" /> 
    </stepAssemblies>
  </specFlow>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup></configuration>

似乎在远程执行测试时,使用的是 NUnit 而不是 MSTest。

“Common.Components.dll”在较早的版本中通过 GacUtil /I 成功部署到 GAC,所以我不知道为什么找不到它?

我尝试直接在远程服务器上运行测试。我打开 RDP,然后打开一个命令窗口并运行“vstest.console Finance.IntegrationTests.dll”。然后我收到无法找到测试输入文件的警告,随后出现错误,因为“无法加载文件或程序集'nunit.framework'”。

我认为问题是,远程执行测试时没有使用集成测试程序集的 App.config。这解释了为什么它尝试使用 NUnit 而不是 MSTest,以及为什么它无法绑定到常用步骤 - 因为它们的位置在节点中给出。

有谁知道我如何在远程测试时使用 App.config?

【问题讨论】:

  • 如何将 Common.Components.dll 部署到 GAC?如果在目标测试机/服务器(DevTest)上手动运行测试,结果如何?
  • 请查看问题的编辑
  • 我不能同时为 SpecFlow 项目安装 SpecFlow.Nuit 和 SpecFlow.MsTest 包,只能安装其中任何一个,并且通过使用 SepcFlow.MsTest 包运行功能测试,测试工作正常。你如何使用它们?您能否分享一个可以在 OneDrive 上重现该问题的简单项目?
  • 很抱歉给您带来了困惑。我不打算使用 NUnit。在本地,我正在使用 Specflow.MsTest。问题是,当远程执行测试时,IntegrationTests.dll 的 App.config 被忽略,因此 Specflow 回退到它的默认测试运行器 - NUnit。我认为,也许可以配置 test.settings 或 run.settings 以便 App.config 不被忽略?

标签: biztalk azure-pipelines azure-pipelines-release-pipeline


【解决方案1】:

有几个问题。我忘记了 app.config 会被编译成 Finance.integrationtests.dll.config。配置中对 dll 的引用需要具有完整的强名称,而不仅仅是名称。

【讨论】:

    猜你喜欢
    • 2020-03-10
    • 2017-03-16
    • 1970-01-01
    • 2011-05-09
    • 2015-09-01
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多