Selenium C# | How to run scenarios based on tags | from cmd prompt and visual studio | BDD framework

preview_player
Показать описание
In this video, we are going to discuss about another important feature in Specflow, tagging.
In Specflow feature file we can assigned tags to features and scenarios.

We can tag our scenario or features as smoke, regression or sanity , and then execute these tests based on the requirement.

As you know that, each time we dont want to run our whole suite of testcases. Sometimes we have to just run smoke test, to test the stability of the product build.

In those cases these tags are really helpful to filter our tests based on these tags.

To run scenarios based on tags, type below command in cmd prompt.

dotnet test --filter TestCategory = Smoke

You can also provide multiple tags, if you want to run scenarios which are marked either with smoke or sanity, then you can use the below command.

and to do that... add the test category string in double quotes...

dotnet test --filter "TestCategory = Smoke|TestCategory=Sanity"

Now, if you want to run the test which contains multiple tags. Lets say only those scenario should get executed which contains smoke and regression both.

Then you can use below command

dotnet test --filter "TestCategory = Smoke&TestCategory=Regression"

And, if you don't want to run the scenario which are marked with sanity and rest all should run. Then you can use below command

dotnet test --filter TestCategory!= Sanity

So this is how we can do the tags based execution in our framework.

***********Please comment in case of any query.***************

Also, please see other videos as well.

Рекомендации по теме
Комментарии
Автор

Can i get full video for building framework with selenium c# specflow from scratch or the version of packages and tools that ur udung

saranyaanbalagan
Автор

my specflow project is based on .net framework and using mstest as test runner. Getting error as 'Determining projects to restore...
Nothing to do. None of the projects specified contain packages to restore.' any suggestions will be helpful

HariKrishnan-cscr
Автор

How to run scenarios sequentially? I tried writing scenarios sequentially the way I want to run - didnt work, Then I tried giving names alphabetically - dint work, gave numbers - didnt work. Please help

apurvapatil
Автор

It was a nice tutorial. But when i am trying to execute it in my cmd command i am getting error: The Folder c:\Program files\ dotnet\host\fxr does not exist. Can you please help?

rubykumari
Автор

How to execute tags based on AND OR condition... example: 1)Run testcases for @regression OR @Smoke... 2) Only run testcases which have both the tags @Smoka @Regression

akshaysoni