running-tests
Running Tests
Once your local Consul Agent is running, you can verify your changes and contributions by running the tests.
PS: Make sure you’ve written or updated unit tests relevant to your contribution.
Option 1: Using Visual Studio's GUI.
If you’re using Visual Studio:
- Open the Test Explorer panel (
Test→Test Explorer). - Build the project to ensure all test assemblies are loaded.
- Select the test or test class you want to run.
You can filter by project or namespace if needed. - Click Run or Debug to execute the selected test(s).
Option 2: Using the Command Line
If you prefer using the command line:
Navigate into the
Consul.Testproject directory.cd Consul.TestRun the tests in the Consul.Test project using the following command:
dotnet testThis command builds the test project and execute all tests, providing output in the terminal that looks like this:
Passed! - Failed: 0, Passed: 124, Skipped: 0, Total: 124For more precision, you can filter the tests by class and even down to a specific test method. For example:
dotnet test --filter FullyQualifiedName~Consul.Tests.AgentThis executes only the tests in the
Consul.Tests.Agentclass.To run a single test method: for example, a test named Catalog_GetServices:
dotnet test --filter FullyQualifiedName=Consul.Tests.Agent.Catalog_GetServices