1

To enable environment configuration, I included an NUnit project as part of the SpecFlow BDD framework (as per Pass parameters via command line to NUnit). But when I try to load it from the command prompt, I am getting the error message

.\nunit-console-x86.exe : Unable to locate fixture.

Command trying to run:

nunit-console-x86.exe example.nunit /config:CI /run:"xxxx.Features.abcdFeature" $dll_dir /result=$result_dir

The framework is as per SpecFlow and Selenium-Share data between different step definitions or classes, using NUnit 2.6.4 and SpecFlow 1.9.

My NUnit project file. Do we need to pass a .csproj file or DLL file in the nunit.exe command above?

<NUnitProject>
  <Settings activeconfig="Default" />
  <Config name="Default" configfile="App.CI.config">
    <assembly path="C:\FuncTest\{ProjectName}\{ProjectName}\bin\Debug\{ProjectName}.dll" />
  </Config>
  <Config name="CI" configfile="App.CI.config">
    <assembly path="C:\FuncTest\{ProjectName}\{ProjectName}\bin\Debug\{ProjectName}.dll" />
  </Config>
  <Config name="UAT" configfile="App.UAT.config">
    <assembly path="C:\FuncTest\{ProjectName}\{ProjectName}\bin\Debug\{ProjectName}.dll" />
  </Config>
</NUnitProject>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ReuseAutomator
  • 410
  • 3
  • 14

1 Answers1

0

I assume that you have a project containing at least one test fixture which looks something like this:

[TestFixture]
public class MyFirstTestFixture{

   [Test]
   public void MyFirstTest(){
      ..
   }
}

So if you project is called myfirstproj.csproj, which contains this fixture, this will produce the following file myfirstproj/bin/debug/myfirstproj.dll.

Note you can replace debug with release, if you compiled it with the release setting. I assume we use debug for now.

Now you create a new NUnit file (in the same folder as the myfirstproj.csproj) file and place the contents like this (I assume you call it myfirstproj.nunit):

<NUnitProject>
  <Settings activeconfig="local"/>
  <Config name="local" configfile="App.config">
    <assembly path="bin\Debug\myfirstproj.dll"/>
  </Config>
</NUnitProject>

Now when you want NUnit you do it like this:

nunit3-console.exe myfirstproj.nunit /config:local

So for the difference between your setup and mine:

  1. Specify the relative path of the DLL file from the NUnit file
  2. Specify that path without placeholders
  3. Execute the test, using the NUnit file

Does this work for you?

If you want to debug this, I would use this steps:

  1. Create first an empty project with just a single unit test
  2. Run that test by executing nunit3-console.exe c:\absolutepath\to\my\project.dll
  3. If the above works, start creating the NUnit file and run it using the NUnit file and see if that works.
  4. Try specifying a configuration and using that configuration for the different environments.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Maarten Kieft
  • 6,806
  • 3
  • 29
  • 34
  • -Thanks, that worked. I was passing the nunit project file in my console to run the tests.Just need to pass .nunit file.But, how to run the same for Release mode? – ReuseAutomator Dec 07 '16 at 01:19
  • You could create 2 nunit files if you want to. But I always use the release version, since I use locally the test explorer from visual studio or nunit tester from resharper. I use the nunit console only in the build server :) – Maarten Kieft Dec 07 '16 at 08:26