user7520525
user7520525

Reputation:

Ignoring a group of TestCases in Nunit

I have some selenium automation test cases written in C# using Nunit3. I wanted to run only a few test cases out of many. Those are basically sanity test cases. How can i achieve this. The entire solution will be run a VSTS so I do not want to run all the test cases every time. I want only sanity test cases to be run. How can i achieve this ..

Upvotes: 0

Views: 542

Answers (3)

Charlie
Charlie

Reputation: 13681

To run using the nunit console runner, assuming you have applied category "sanity" to the appropriate tests.

nunit3-console.exe mytests.dll --where "cat=sanity"

To do the same thing using the vstest runner

vstest.console.exe mytests.dll /TestCaseFilter:"TestCategory=sanity"

Upvotes: 1

Bendram
Bendram

Reputation: 120

Since you are using VSTS to execute the tests you can group the tests using traits(test category)

enter image description here

You can exclude the category or group you do now want to execute while running the tests from Test Explorer.

Do you know you can run the tests from the command prompt as well? It is even easier to ignore the test cases of a specific category. The following mstest command will execute all the tests in the MyTestProjectName dll except the category - IgnoredGroupName

mstest /testcontainer:MyTestprojectName.dll /category:"!IgnoredGroupName"

Upvotes: 0

anArchLolz
anArchLolz

Reputation: 1

Is it the same 'few tests' out of many that you want to run every time? If so I'd suggest separating those 'few tests' into a separate project under the same solution.

There are other ways to achieve what you want i.e. using @tags but from what you have said moving those tests to a separate project will be the easiest and most efficient way to achieve what you are asking for.

Upvotes: 0

Related Questions