Pass NUnit Test Category through command line

544 Views Asked by At

I am trying to use NUnit Category attribute to run a set of tests at a time.

But how to pass the category as an argument while running the tests from command line?

Tried multiple things, but none of them seems to be working:

dotnet test /include Category=AfterReboot mytests.dll --> Error:The argument /include is invalid. Please use the /help option to check the list of valid arguments.

dotnet test --filter Category=AfterReboot mytests.dll --> Error:The argument --filer:category=AfterReboot is invalid. Please use the /help option to check the list of valid arguments.
2

There are 2 best solutions below

0
On

Figured it out. Belor worked.

dotnet test --filter "Category = AfterReboot" mytests.dll

2
On

The correct filter is TestCategory with dotnet 6.0.400

dotnet test --filter TestCategory=CategoryA