Skip to content

Add NUnit .NET example using bktec custom runner for test splitting#39

Open
pda wants to merge 6 commits intomainfrom
nunit
Open

Add NUnit .NET example using bktec custom runner for test splitting#39
pda wants to merge 6 commits intomainfrom
nunit

Conversation

@pda
Copy link
Copy Markdown
Member

@pda pda commented Mar 27, 2026

Adds an NUnit/.NET example demonstrating test splitting with bktec using BUILDKITE_TEST_ENGINE_TEST_RUNNER=custom.

Since bktec doesn't have built-in NUnit support, this example uses a custom runner to split .cs test files across parallel agents and map them to dotnet test --filter expressions.

How it works

  • bin/test builds the solution, installs bktec, and configures the custom runner with BUILDKITE_TEST_ENGINE_TEST_FILE_PATTERN=tests/**/*Tests.cs
  • bktec discovers test files, gets a split plan from the API, and invokes bin/run-tests with the assigned files
  • bin/run-tests extracts class names from the .cs file paths and builds a dotnet test --filter "FullyQualifiedName~.CalculatorTests|..." expression

Pipeline details

  • Uses the mise plugin (instead of Docker) to install the .NET SDK
  • parallelism: 2 for test splitting across agents
  • test-collector plugin uploads JUnit XML results with language.name=dotnet and test.framework.name=nunit tags

Test suite

25 NUnit tests across 3 files: CalculatorTests, StringUtilsTests, SimpleStackTests.

pda and others added 5 commits March 27, 2026 12:21
- Add bin/run-tests custom runner that maps .cs file paths to dotnet
  test --filter expressions by class name
- Update bin/test to install bktec and configure custom runner with
  TEST_FILE_PATTERN=tests/**/*Tests.cs
- Build solution upfront so run-tests can use --no-build
- Add parallelism: 2 and API access token to pipeline step

Amp-Thread-ID: https://ampcode.com/threads/T-019d2d0d-68c7-731c-b8dc-f482d3d473d4
Co-authored-by: Amp <amp@ampcode.com>
@pda pda marked this pull request as ready for review March 27, 2026 05:11
@pda pda changed the title NUnit example test suite (no bktec / Test Engine yet) Add NUnit .NET example using bktec custom runner for test splitting Mar 27, 2026
@pda pda requested a review from ccuadrado-buildkite March 27, 2026 05:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd9670b053

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

nunit/bin/test Outdated

# Install Buildkite Test Engine Client
# See https://buildkite.com/docs/test-engine/test-splitting/client-installation
if [ -z "${BKTEC_VERSION}" ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a nounset-safe BKTEC_VERSION guard

Because the script enables set -u, expanding "${BKTEC_VERSION}" here throws an unbound variable error when the variable is missing, so the intended diagnostic and exit path on the next lines never runs. In any environment where BKTEC_VERSION is not populated (for example local runs or CI misconfiguration), this causes a hard failure with a less actionable message than the script is explicitly trying to provide.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant