Back
Blog

Faster .NET CI/CD Pipelines With Test Filters

Jan 15, 2021

By Ryan Taylor

Share:
  • linkedin
  • facebook
  • instagram
  • twitter

Sluggish integration and delivery pipelines leave developers vulnerable to distraction. If your unit and integration tests live in one .csproj and run in both CI and CD, tune your pipeline stages to run only relevant tests.

The Tests

[Fact]
[Trait("Category","Unit")]
public async Task ThisTest_ShouldBeAUnitTest() 
{
   // Useful unit test
} 

[Fact]
[Trait("Category","Integration")]
public async Task WhenThisThingDoesX_ThatThingShouldDoY() 
{
   // Useful integration test
}

Tuning the Pipelines

To run only unit tests in CI: dotnet test --filter Category=Unit

To run only integration tests in CD: dotnet test --filter Category=Integration

--- Photo credit: Andrew Parnell

Back to Explore Focused Lab
/Contact us

Let’s build better software together