Need help with running Specflow with Nunit.

97 views
Skip to first unread message

Jav Ainesaz

unread,
Jun 20, 2018, 12:36:05 PM6/20/18
to SpecFlow
I would appreciate if someone could tell me why I am unable to run my NUnit tests in the Specflow.
All my test run fine when I have the following  in the app.config;

<specFlow>
     <unitTestProvider name="SpecRun" /><plugins>
      <add name="SpecRun" />
    </plugins>
  </specFlow>

However when I change the app.config to use Nunit;

<specFlow>
     <unitTestProvider name="NUnit" /><plugins>
      <add name="NUnit" />
    </plugins>
  </specFlow>

I get the following error reported in the test runner;

Message: Object reference not set to an instance of an object.

I have ;

Visual studio 2017 Version: 15.7.3
NUint Version referenced : 3.10.1.0
SpecRun.SpecFlowPlugin Version: 1.7.2.0
TechTalk.SpecFlow version: 2.2.0.0
TechTalk.SpecRun version: 1.7.2.0
TechTalk.SpecRun.Common:  1.7.2.0

Referenced dlls are;








Jav Ainesaz

unread,
Jun 21, 2018, 7:05:14 AM6/21/18
to SpecFlow
This problem is resolved by following the workaround mentioned in http://specflow.org/documentation/Generate-Tests-from-MsBuild/

Jav Ainesaz

unread,
Jun 21, 2018, 7:37:19 AM6/21/18
to SpecFlow

I think I jumped the gun a bit too early in responding to my own previous post in saying that the issues was resolved. In fact this issue seems to exist even after following the steps mentioned in the http://specflow.org/documentation/Generate-Tests-from-MsBuild/

Just a correction to me initial post regarding the app.config settings;

When I use the following section in the app.config the tests fail with the message Message: Object reference not set to an instance of an object.

<specFlow>

     <unitTestProvider name="NUnit" />

  </specFlow>



On Wednesday, 20 June 2018 17:36:05 UTC+1, Jav Ainesaz wrote:

Vrushali

unread,
Jun 22, 2018, 8:21:36 PM6/22/18
to spec...@googlegroups.com
Jav
Please try vstest.console.exe 
Msbuild is old and i did have problem with nunit so vstest works best 
Thanks 
Vrushali

--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Willich

unread,
Jun 25, 2018, 4:13:46 AM6/25/18
to SpecFlow
I think you mixed technologies. ;-)

MSBuild is the build engine for .NET. Except compiling the test assembly, it has nothing to do with testing.
VSTest is the test platform for .NET. It executes the tests for different testing frameworks with test adapters.

MSTest is the test framework from Microsoft. That's old. But there is now V2 (https://www.nuget.org/packages/MSTest.TestFramework/) which is the acutal version.
NUnit and XUnit are like MSTest a test framework.

@Jav:
If you want to use NUnit, you don't need the packages with SpecRun in the name. These are the packages of the SpecFlow+Runner.


BR
Andreas

Jav Ainesaz

unread,
Jun 25, 2018, 4:53:16 AM6/25/18
to SpecFlow
Andreas;
Regarding your comment " think you mixed technologies. ;-)"
I wonder if you have read my post or even understood it! 
I am not sure what you are talking about. I have made no references to any of the technologies  you are referencing (e.g. MSBuils etc etc.)


Vrushali thank you for your help. But I really need to use Nunit.

Andreas Willich

unread,
Jun 25, 2018, 5:05:21 AM6/25/18
to SpecFlow
I wasn't referencing anything from you Jav.

I was referencing on this post:

Jav Ainesaz

unread,
Jun 26, 2018, 4:14:09 AM6/26/18
to SpecFlow
Thank you Andeas,
But   the generated  *.feature.cs file references these packages. Removing them produces compilation error.
Are the following lines in the app.config sufficient for NUnit, or is there anything else that required.

<specFlow>
 <unitTestProvider name="NUnit" />
</specFlow>

Andreas Willich

unread,
Jun 26, 2018, 7:42:30 AM6/26/18
to spec...@googlegroups.com
Did you regenerate the code-behind files when you changed the unitTestProvider?
There should have been a popup in VS with a question if it should do this.

You can do it afterwards for all files in the context menu of the project. There is an entry "Regenerate Feature Files" near the bottom.

Jav Ainesaz

unread,
Jun 26, 2018, 8:36:58 AM6/26/18
to SpecFlow
Thank you Andeas, 

That worked.

Best wishes

Vrushali

unread,
Jun 26, 2018, 10:10:43 PM6/26/18
to spec...@googlegroups.com
You welcome Jav
All i mean to say in that post is you can try vstest ,I used it and it did work for me .My reply was based on I got same question answered on github .Apologies if it sound wiered. 
Thanks 
Vrushali
Reply all
Reply to author
Forward
0 new messages