Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i specify specflow tags in nunit console 3 command line options to filter the test scenarios? #306

Closed
honeynair opened this issue Oct 27, 2017 · 12 comments
Labels

Comments

@honeynair
Copy link

honeynair commented Oct 27, 2017

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

@rprouse
Copy link
Member

rprouse commented Oct 27, 2017

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

@honeynair
Copy link
Author

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

Thanks
Honey

@rprouse
Copy link
Member

rprouse commented Oct 27, 2017

@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.

@rprouse rprouse closed this as completed Oct 27, 2017
@rprouse rprouse added this to the Closed Without Action milestone Oct 27, 2017
@anilkumar897
Copy link

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?

@mikkelbu
Copy link
Member

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".

@anilkumar897
Copy link

@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.

@CharliePoole
Copy link
Collaborator

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

@CharliePoole
Copy link
Collaborator

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

@mikkelbu
Copy link
Member

@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"

@anilkumar897
Copy link

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

@anilkumar897
Copy link

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

@mikkelbu
Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants