gpt4 book ai didi

unit-testing - 由于找不到 "TechTalk.SpecFlow"文件,SpecFlow 单元测试失败

转载 作者:行者123 更新时间:2023-12-04 04:46:34 26 4
gpt4 key购买 nike

我有一个设置为使用 SpecFlow 1.8.1 和 mstest 的 VS2010 单元测试项目。为了让 SpecFlow 单元测试正常工作,我做了以下工作:-

  • 我在我的项目中添加了对以下文件的引用:-
    Microsoft.VisualStudio.QualityTools.UnitTestFramework.dllTechTalk.SpecFlow.dll

    Note that the TechTalk.SpecFlow.dll has been added into my project and the reference points to that file.

  • I've set the "Copy Local" property of the TechTalk.SpecFlow.dll reference to True.

  • I've also added an App.Config that specifies "MsTest.2010" as the provider, and regenerated all code-behinds for the SpecFlow features.

  • Everything works in my VS2010, the tests run successfully in both the SpecFlow testrunner and the mstest test runner. BUT when I try to run the mstests in TFS 2008 (using a .vsmdi test list file), it failed with the following exception:-

    Class Initialization method MyNamespace.MyTestFeature.FeatureSetup threw exception.
    System.Configuration.ConfigurationErrorsException:
    System.Configuration.ConfigurationErrorsException: An error occurred creating the
    configuration section handler for specFlow: Could not load file or assembly
    'TechTalk.SpecFlow' or one of its dependencies. The system cannot find the file
    specified. (D:\Projects\TestProject\TestResults\administrator_MYPC 2012-06-27
    18_30_05_Any CPU_Debug\Out\TestProject.DLL.config line 4) --->
    System.IO.FileNotFoundException: Could not load file or assembly 'TechTalk.SpecFlow'
    or one of its dependencies. The system cannot find the file specified.

    请注意,TFS 很好地构建了项目,并且它在同一项目(正常的 mstests,而不是 SpecFlow)中运行其他单元测试没有问题。它仅在 SpecFlow 测试运行中失败。

    那么我做错了什么?

    编辑:我的 App.Config 文件的内容如下所示:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <configSections>
    <section
    name="specFlow"
    type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
    </configSections>
    <specFlow>
    <unitTestProvider name="MsTest.2010" />

    <runtime detectAmbiguousMatches="true"
    stopAtFirstError="false"
    missingOrPendingStepsOutcome="Inconclusive" />

    <trace traceSuccessfulSteps="true"
    traceTimings="false"
    minTracedDuration="0:0:0.1" />
    </specFlow>
    </configuration>

    最佳答案

    按照 this site 上的说明进行操作和 this site :

    命令 Tools > Library Package Manager > Package Manager Console允许您输入 PM> Install-Package SpecFlow
    当提示返回“安装成功”时,SpecFlow 程序集现在出现在您项目的引用中。现在 MSTest 项目编译成功(至少对我而言)。

    关于unit-testing - 由于找不到 "TechTalk.SpecFlow"文件,SpecFlow 单元测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11221023/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com