Running a specific test with .NET Core and NUnit
January 23, 2017 by Anuraj
dotnet core NUnit unit test
This post is about running a specific test or specific category with .NET Core and NUnit. dotnet-test-nunit is the unit test runner for .NET Core for running unit tests with NUnit 3.
First you need to enable NUnit in dotnet core.
Here is the tests file.
And you can run dotnet test
, which will run all the tests in the class.
If you have lot of tests, you can seperate the tests with categories, something like this.
I have a set of unit tests and another set of integration tests. And if you want to run unit tests only you can pass the parameter and execute the unit tests only.
Here is the command, dotnet test --where "cat == Unit"
, which will execute the tests under Unit category.
If you want to run a specific test, you can do that as well using dotnet test --test Test2
command. You can find more details and command in the NUnit Console Command Line
Happy Programming :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub