How do I run a test
  • 24 Nov 2022
  • 1 Minute to read
  • Contributors
  • Comment
  • Dark
    Light
  • PDF

How do I run a test

  • Comment
  • Dark
    Light
  • PDF

The video below will give you a short walk through on how to run a test from the terminal in vs code

You can run tests from the terminal in vs code and the output will be displayed in the terminal output.

Run tests:

dotnet test --logger:"console;verbosity=normal"

Results:
image.png

Useful Commands

Run an individual test

dotnet test --filter FullyQualifiedName=logicapp.testing.unittests.Workflows.Echo.MsTest.Tests.Echo_GreenPath --logger:"console;verbosity=normal"

Run all tests in vscode

dotnet test --logger:"console;verbosity=normal"

Run tests with verbose logging to help troubleshooting

dotnet test --logger:"console;verbosity=detailed"

Run Tests with a category

Running tests with a category will allow me to run just the mstest or just the specflow tests.

MsTest unit tests

If we use an attribute on the test like below then the test category allows us to specify a category for a test

[TestMethod, Priority(1), TestCategory("UnitTests")]

We can then run specific tests using a filter

dotnet test --filter TestCategory=UnitTests

Specflow Tests

If we are using specflow we can put a tag on the tests such as @SpecflowTests

image.png

then we can use the below command to run just the specflow tests

dotnet test --filter TestCategory=SpecflowTests

Run Tests with a filter on priority

dotnet test --filter Priority=1

Was this article helpful?