Loading NUnit project file (example.nunit) during Specflow feature execution

五迷三道 提交于 2019-12-06 23:42:28
Maarten Kieft

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!