.NET collector
To use Buildkite Test Engine with your .NET projects, either use the Tests Buildkite plugin to run your NUnit tests through bktec, or use the
test-collector-dotnet package with xUnit.
The recommended way to set up a new test suite is to add the Tests Buildkite plugin to the step that runs your tests. It works with every runner that bktec supports, and the entire setup is configuration-only — you can get a test suite running through changes to pipeline.yml alone, with no modifications to your application code.
Use the language-specific test collector documented on this page when you want deeper framework integration — such as custom execution tags, span annotations, or richer per-framework data. Language-specific collectors still pair well with the Tests Buildkite plugin, but adding one requires changes to your application code.
You can also upload test results by importing JSON or JUnit XML.
Tests Buildkite plugin example for NUnit
The following step uses the Tests Buildkite plugin to run an NUnit suite through bktec. The plugin downloads bktec, requests an OIDC token, ensures the test suite exists, and exports the environment variables that bktec expects. Build your solution first so that each partition can run with --no-build, then invoke bktec run:
steps:
- label: "NUnit"
command:
- dotnet build
- bktec run
plugins:
- tests#v1.0.0:
test-runner: nunit
result-path: test-results/results.xml
test-file-pattern: "tests/**/*Tests.cs"
parallelism: 4
See the Tests Buildkite plugin page for the full plugin reference, including all supported options and dynamic parallelism with bktec plan.
xUnit collector
Before you start, make sure .NET runs with access to CI environment variables.
Create a test suite and copy the API token that it gives you.
-
Add
Buildkite.TestAnalytics.Xunitto your list of dependencies in your xUnit test project:$ dotnet add package Buildkite.TestAnalytics.Xunit -
Set up your API token
Add the
BUILDKITE_ANALYTICS_TOKENenvironment variable to your build system's environment. -
Run your tests
Run your tests like normal. Note that we attempt to detect the presence of several common CI environments, however if this fails you can set the
CIenvironment variable to any value and it will work.$ dotnet test Buildkite.TestAnalytics.Tests Verify that it works
If all is well, you should see the test run analytics on the Buildkite Test Engine dashboard.