
In software development, it’s crucial to ensure the quality and reliability of your code. Testing plays a significant role in achieving this, and different types of tests can be employed for various purposes. In this post, we will discuss how to exclude C# integration tests from your GitHub Actions workflow to improve the efficiency of your CI/CD pipeline.
Unit tests are focused on testing individual components or functions in isolation, ensuring that each part of the codebase works as expected. On the other hand, integration tests check how different parts of the system interact and collaborate, validating the overall behavior of the application.
Separating unit tests and integration tests in the CI/CD pipeline provides several benefits:
Consider a web application where unit tests cover the individual components, while integration tests validate end-to-end scenarios, including interactions with databases and third-party services. Running integration tests alongside unit tests on every commit can be time-consuming and resource-intensive. Excluding integration tests from the GitHub Actions workflow and running them separately or on a scheduled basis can save time and resources, allowing developers to focus on their code changes.
To exclude a test project from GitHub actions, you can run the test command with a filter, specifying the namespace of the project you want to exclude:
dotnet test --filter FullyQualifiedName!~name.space.you.want.to.exclude --configuration Release
You can then incorporate this command into your GitHub actions workflow like this:
name: .NET Coreon:push:branches:- main # Your default release branchjobs:build:runs-on: windows-lateststeps:- uses: actions/checkout@v2- name: Setup .NET Coreuses: actions/setup-dotnet@v1with:dotnet-version: 5.0.101- name: Build and Test with dotnetrun: dotnet test --configuration Releaserun: dotnet test --filter FullyQualifiedName!~name.space.you.want.to.exclude --configuration Release
By following these steps, you can efficiently exclude integration tests or any other test project from your GitHub Actions workflow.
By filtering out tests based on their namespace, you can exclude specific test projects from your GitHub actions workflow. This is particularly useful when you want to exclude integration tests from your build process.
For more information on using GitHub Actions with .NET Core, as well as other advanced topics and best practices, consider exploring the following resources:
These resources should provide you with a deeper understanding of how to set up, customize, and optimize your GitHub Actions workflows for .NET Core projects.
We’d love to hear your thoughts on this tutorial! If you have any questions or suggestions for improvement, please don’t hesitate to reach out. You can leave a comment below, or you can contact us through the following channels:
We’ll do our best to address any questions or concerns you may have. We look forward to hearing from you and helping you make the most of GitHub Actions and .NET Core testing in your projects!
Quick Links
Legal Stuff




