0

I'm using SpecFlow in VS 2015 to create Selenium Webdriver automation tests (though that's not relevant to this question.) Outside of Visual Studio I run the tests with nunit3-console.exe.

Inside VS my App.config is setup for <unitTestProvider name="SpecRun+NUnit" />

My question relates to how scenarios appear in Test Explorer. If I create a feature file "FooTest.feature" with a single scenario "Add foo numbers" with tag @mytag, this is what shows in Test Explorer when I group by traits:

Test Explorer grouped by trait

Or if I group by class I get:

Test Explorer grouped by Class

Do I have any control over this? Or is this just the way it works? Ideally I would just want to view the 'mytag' entry. (Or Category [mytag]. Just not all of them!)

1 Answer 1

0

With SpecRun+NUnit you are generating unit tests in the code behind file for the SpecFlow+Runner (SpecRun) and NUnit. Visual Studio finds them both and so you get everything double. Is there a reason why you have this configuration? Why do you need the NUnit tests? If you are using SpecFlow+Runner, you have to configure it only to SpecRun

6
  • Good question. I am using nunit console to run tests from continuous integration, and I'm using some nunit specific capabilities in some of my tests. But this could be one of those things that I tried out when I was experimenting thinking it was needed. I will try running without that setting and see if there is any impact. Maybe it's worth asking the question: When would someone need to use SpecRun+NUnit?
    – Joel
    May 31, 2017 at 15:43
  • I gather the +NUnit is required if you want to run tests with nunit console because if I change unitTestProvider to SpecRun that stops working. Maybe the TestExplorer display is just something I have to live with.
    – Joel
    May 31, 2017 at 16:32
  • if you configure SpecRun, you have to use the specrun.exe command line to execute the tests. The SpecRun.Runner package contains an VS test adapter so that you see the tests in the test explorer. But it looks like you do not want to use SpecFlow+Runner, but NUnit. In that case you configure the unittestprovider simply to NUnit. In that case, you want to add the NuGet package NUnit3TestAdapter. This has the VS Test adapter for NUnit included. In that case, I would remove all SpecRun packages from your project. May 31, 2017 at 16:53
  • @Joel As a developer of the SpecFlow+Runner I would be interessted which NUnit specific features are you using. Perhaps there are already available in the runner. May 31, 2017 at 16:57
  • Andreas, thanks for the comments. I started out using SpecRun a while back, and had some difficulty accomplishing what I wanted when trying to integrate with TeamCity. I will try to recall what that was and get back to you. It could be if i started today I wouldn't have needed to switch to NUnit. My tests produce a bunch of nunit2 format xml files, I have a utility that combines them into a single xml file, and I still use specrun.exe to generate an html report after my tests are run.
    – Joel
    May 31, 2017 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.