Shibu Thannikkunnath
Shibu Thannikkunnath

Reputation: 311

How to run Nunit tests belongs to specific Namespace using ConsoleRunner

Is it possible to run NUnit tests that belong to a specific namespace in my .Net application? I tried to explore the commands that are available in NUnit online documentation and couldn't find commands to run tests in a namespace.

I have following structure in my application.

+AwesomeApp
+---AwesomeApp.WebApp
+---AwesomeApp.Services
+---AwesomeApp.WebApp.Tests
    +----AwesomeApp.WebApp.Tests.Unit
        +----UnitTest #1
        +----UnitTest #2
    +----AwesomeApp.WebApp.Tests.Integration
        +----IntegrationTest #1
        +----IntegrationTest #2
    +----AwesomeApp.WebApp.Tests.Regression
        +----RegressionTest #1
        +----RegressionTest #1

Note: each namespace within "AwesomeApp.WebApp.Tests" has many unit tests

I'm trying to figure out the commands to run all tests that are in AwesomeApp.WebApp.Tests.Unit, AwesomeApp.WebApp.Tests.Integration and AwesomeApp.WebApp.Tests.Regression separately. This is mainly because the Unit tests have to run after every build, regression tests have to run once a month and Integration tests are manually triggered by developers in their local system,

or is there a better way to achieve this? Appreciate your help.

Upvotes: 2

Views: 1590

Answers (1)

Rob Prouse
Rob Prouse

Reputation: 22647

In the NUnit 3 console runner, you use the --where command line option with the Test Selection Language. For example,

nunit3-console.exe AwesomeApp.WebApp.Tests.dll --where "namespace == AwesomeApp.WebApp.Tests.Unit"

For developers running tests in Visual Studio, group your tests by namespace and run the namespaces,

enter image description here

enter image description here

Upvotes: 2

Related Questions