Unable to successfully run NUnit tests with SpecFlow+ Runner
AnsweredI'd like to include SpecFlow and NUnit tests in the same project, and use the SpecFlow+ Runner (SR) to take advantage (hopefully) of the test execution reports, Targets, etc. available with SR. This seems possible based on the "Migration to SpecFlow+ Runner" documentation, however, I'm unable to successfully run NUnit tests with SR.
SpecFlow tests run and work as expected. NUnit tests run for 3 seconds, produce the Log file and Report file (it's blank) in the Tests Output. but the test doesn't actually run. Output also shows, "No test matches the given testcase filter".
As a side note, the same exact SpecFlow and NUnit tests work as expected when the project is setup to use NUnit runner (VS2019 SpecFlow project template, and NUnit Test Framework).
Is it possible to have SpecFlow and NUnit tests exist in the same project and use SpecFlow+ Runner? If yes, what may be causing the NUnit test run issue?
Related Packages: Microsoft.NET.Test.Sdk 16.11.0, NUnit 3.13.2, SpecFlow.Plus.LivingDocPlugin (3.9.57), and SpecRun.SpecFlow (3.9.7).
Targeting .NET 5.0.
-
Hi Carter Rohmiller,
Are you able to send the project to info@specflow.org?
I believe I understand the issue but the answer would depend on the project specific setup. I feel there might be some ambiguity between 'test frameworks' and 'test runners'
0 -
Hello Jordan,
Yes, I sent a sample project over.
Thanks,
Carter
0 -
Hi Carter Rohmiller,
thanks for sending the project, I think the only solution would be to have your NUnit tests in one project, and your specflow tests in another, and the reason is that the tests need to be behind a feature file, not just methods decorated with the NUnit attributes (for the SF runner)
0 -
Hi Jordan--
Thanks for the quick response. I'm a little confused on SpecFlow's integration with NUnit (among other test frameworks) then. How is Nunit supposed to be used with Specflow in this case? You mention the NUnit tests need to be behind a feature file - how is this done or supposed to work? I don't see any specific documentation on this feature so any additional detail here will help us understand this piece much better.0 -
Hi Carter,
(Posting this here for the sake of others in case they also have the same question)
The integration means that your something.feature.cs (the ‘code behind’ file) is generated in such a way that the test is recognisable by your chosen execution engine, in this case, NUnit’s test runner.
For example, when we build the solution, the .cs file is generated based on which packages you have installed, in this case, NUnit. If we look in the .cs file, you will see tests generated that contain attributes pertaining to which framework you are using, such as this TestFixtureAttribute which belongs to NUnit.Framework –
This allows the tests to be picked up correctly by your chosen execution engine.
I suppose in a nutshell, you could say that SpecFlow is parsing the feature files into appropriate tests for your runner of choice.
Does this help at all?
Thanks, Jordan.
0 -
Ah ok – so this at least clears up what the integration is all about. Marrying feature files into other runners – seems we were pretty close but glad to get more detail on this!
In a nutshell, when it comes to other test frameworks in the same solution, we'll have to use their "native" runner for both SpecFlow tests and their tests. If we choose to use SpecFlow+ Runner for SpecFlow tests, we'll have to separate the projects for each test framework since SpecFlow+ Runner is unable to run tests from other frameworks.
Thanks Again!
0
Please sign in to leave a comment.
Comments
6 comments