NUnit GUI 运行程序无法识别 SpecFlow 的 App.config

发布于 2024-09-03 19:31:22 字数 903 浏览 1 评论 0原文

如何让 NUnit GUI 运行程序识别/使用我的 App.config 文件?我尝试将其放在项目的顶部文件夹中,并与我的功能文件放在同一文件夹中。以下是我的 App.config 文件的内容:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>

  <specFlow>
    <runtime detectAmbiguousMatches="true"
             stopAtFirstError="false"
             missingOrPendingStepsOutcome="Error" />
  </specFlow>
</configuration>

具体来说,我试图告诉 NUnit 在缺少或待处理的步骤时出现失败结果,这就是我为此指定“错误”的原因。当我使用 TestDriven.net 时,这实际上可以正常工作,但当我使用 NUnit GUI 运行程序时却不能。 GUI 始终显示绿色条并将测试显示为“不确定”,而不是“错误”或“失败”。

我使用以下命令行参数启动 GUI:

E:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit.exe "E:\ACSreader new work\ACSreader2working Copy\trunk\ACSreader2\ACSreader2.sln “/配置:测试

How do I get my App.config file to be recognized/used by the NUnit GUI runner? I have tried placing it in the top folder of my project and in the same folder as my feature files. Here are the contents of my App.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>

  <specFlow>
    <runtime detectAmbiguousMatches="true"
             stopAtFirstError="false"
             missingOrPendingStepsOutcome="Error" />
  </specFlow>
</configuration>

Specifically I am trying to tell NUnit to have a fail result when there is a missing or pending step which is why I am specifying "Error" for this. This actually works correctly when I use TestDriven.net but not when I use the NUnit GUI runner. The GUI always shows a green bar and displays the test as Inconclusive instead of Error or Failed.

I am launching the GUI with this command line argument:

E:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit.exe "E:\ACSreader new work\ACSreader2 Working Copy\trunk\ACSreader2\ACSreader2.sln" /config:Test

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半衬遮猫 2024-09-10 19:31:22

有关 NUnit GUI Runner 的更新:

NUnit-Runner 似乎无法正确显示/报告不确定的测试。不确定的测试在 NUnit-GUI 中显示为绿色,而 TestDriven 和 ReSharper 将其显示为黄色。

如问题所示,SpecFlow 可以配置为将缺失的步骤报告为错误而不是不确定。

配置发生在包含功能文件的项目的 App.config 中。应用.NET 中 App.config 的常用机制。这意味着在运行时配置信息必须位于名为 .dll.config 的文件中。然后,运行时将配置提供给 SpecFlow。 SpecFlow 不会从 App.config 读取配置本身!

确保在运行时正确命名的配置文件与包含测试装置的 dll 一起存在。 VisualStudio 通常在构建项目时透明地执行此操作。

原始答案:

App.config 必须位于包含测试装置的项目(包含功能文件的项目)的根文件夹中。

看看 github 上的例子。不同的项目中有多个 App.config 文件:

http://github.com/techtalk/SpecFlow-Examples/tree/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests/

http://github.com/techtalk/SpecFlow-Examples/tree/master /ASP.NET-MVC/BookShop/BookShop.AcceptanceTests.Selenium/

http://github.com/techtalk/SpecFlow-Examples/tree/master/BowlingKata/BowlingKata-MsTest/Bowling.SpecFlow/

Update concerning NUnit GUI Runner:

NUnit-Runner seems not to properly display/report inconclusive tests. An inconclusive test is displayed green in NUnit-GUI, while TestDriven and ReSharper display it yellow.

As shown in the question, SpecFlow can be configured to report missing steps as Errors and not as Inconclusive.

The configuration happens in the App.config of the project that contains the feature-files. The usual mechanism for App.config in .NET is applied. That means at runtime the config info has to be in a file called .dll.config. The runtime provides then the config to SpecFlow. SpecFlow does not read the config itself from App.config!

Make sure that at runtime the correctly named config file is present alongside the dll that contains the test fixtures. VisualStudio usually does that transparently when building a project.

Original answer:

The App.config has to be in the root folder of the project that is containing the test-fixtures (the project that contains the feature files).

Have a look at the examples on github. There are several App.config files in different projects:

http://github.com/techtalk/SpecFlow-Examples/tree/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests/

http://github.com/techtalk/SpecFlow-Examples/tree/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests.Selenium/

http://github.com/techtalk/SpecFlow-Examples/tree/master/BowlingKata/BowlingKata-MsTest/Bowling.SpecFlow/

幸福还没到 2024-09-10 19:31:22

查看我的答案nunit 和配置
您需要告诉 nunit 配置文件的名称是什么。它默认查找namespace.config,它接缝

See my answer nunit and configs
You need to tell nunit what the name of the config file is. it looks for namespace.config by default it seams

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文