Faster .NET CI/CD pipelines with test filters

Faster .NET CI/CD pipelines with test filters:

 

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

from Tumblr https://generouspiratequeen.tumblr.com/post/640454870605971456

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s