Nunit-console: How can i specify specflow tags in nunit console 3 command line options to filter the test scenarios?

Created on 27 Oct 2017  路  12Comments  路  Source: nunit/nunit-console

I am using specflow 2.2.1 and nunit 3 with Visual studio 2015 for selenium testing.
Wanted to run tests based on tags using nunit console say 1 or 2 from a feature files which has got 5 or 6 scenarios.

I have tags like this
@Login @Desktop @WIP
Feature: Login
This is to test the login functionality of the site

Please help

Thanks
Honey

question

All 12 comments

By tags are you talking about NUnit categories or are Tags a SpecFlow construct? If the later, you will need to ask there as most of the NUnit team doesn't use SpecFlow. If it is categories, then you can specify using a -where clause on the command line. See https://github.com/nunit/docs/wiki/Test-Selection-Language

@rprouse Thank you. It is Specflow tags. Sorry to confuse you. But glad that figured out the category from the above link.

Thanks
Honey

@honeynair I am going to close this as a question. If you still need NUnit specific help, comment here, we will see it and try to help.

HI All,

Just started using SpecFlow with Nunit have a query listed below

Is it possible to execute the selected Tag Scenarios in a Feature File by NUnit console runner

For e.g. Consider a feature File as

Feature: Login

@IE
Scenario: Scenario1
Given........
When.....
Then...

@IE
Scenario: Scenario2
Given........
When.....
Then...

@Chrome
Scenario: Scenario3
Given........
When.....
Then...

So, I need to execute all the @IE tagged Scenarios belong to Login Feature by NUnit Console Runner.
Can anyone please help me out?

If I understand SpecFlow's documentation correctly, then Tag Scenarios are translated into categories, so you should be able to run them using something like nunit3-console mytest.dll --where "cat == ie".

@mikkelbu Thank you.
Yes, I tried with the same command. But it executed all the scenarios of all other features tagged to ie. But I want to execute only the scenario to a particular feature.

In that case you need to combine the feature name with the category. How do you select a single feature to run?

It's ridiculous that this isn't easier to figure out!

@anilkumar897 if https://stackoverflow.com/a/33920759 is correct then the name of the feature is used as a description in a DescriptionAttribute on the class containing the test. If that is the case then you can filter on this also. So you will end up with something like

.\nunit3-console.exe mytest.dll --where="Description=='Login' and cat == ie"

Thank you so much @mikkelbu.
Yes, it worked :)

Hi All,
Any idea how we can achieve same in vstest console.exe ?

I'm sorry, but I don't have any idea. I think it is better to ask in either the microsoft/vstest project or perhaps nunit/nunit3-vs-adapter, but as far as I know there are some concepts that are not transferred from NUnit to vstest (see e.g. microsoft/vstest#98).

Was this page helpful?
0 / 5 - 0 ratings