English 中文(简体)
App.config for SpecFlow not recognized by NUnit GUI runner
原标题:

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 FilesNUnit 2.5.5in et-2.0 unit.exe "E:ACSreader new workACSreader2 Working Copy runkACSreader2ACSreader2.sln" /config:Test

问题回答

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/

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





相关问题
How do I ignore a test based on another test in NUnit?

I m writing some NUnit tests for database operations. Obviously, if Add() fails, then Get() will fail as well. However, it looks deceiving when both Add() and Get() fail because it looks like there s ...

result.viewname is always string.empty

I cannot seem to return the result.ViewName for use in Nunit tests as it always returns string.empty. I have explicitly set the name of the view inside my controller and would expect the test to pick ...

C#: How to test a basic threaded worker class

I m dipping my toes in how to test multi-threaded stuff, but not quite sure how to get started. I m sure I will figure more stuff out easier if I could just get stuff going, so I was wondering if ...

Selenium Grid with parallel testing using C#/NUnit

I ve got several unit tests written with NUnit that are calling selenium commands. I ve got 2 win2k3 server boxes setup, one is running selenium grid hub along with 2 selenium rc s. The other box is ...

Code coverage with nUnit? [closed]

Is there a way to see the code coverage when using nUnit? I know there s such a feature in Visual Studio, but can you use it with nUnit or only with the built-in vs unit tests?

Unit testing database-dependent Window services

We have a set of services in .NET 3.5C# and WCF. The NUnit tests need the services to be running and listening for requests. The services need an updated SQL database to be ready for connection. ...

TeamCity NUnit test result visualisation

Is there any way to produce visual results of NUnit tests from within TeamCity s "Tests" tab, currently my NAnt script outputs an .xml file of the results using the following task: <nunit2 ...

热门标签