From 8d2b4243c1b4ec25e74f404117ecc4c378788626 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:19:16 +0000 Subject: [PATCH] feat: add TUNIT_DISABLE_LOGO environment variable support Add support for configuring --disable-logo via the TUNIT_DISABLE_LOGO environment variable. This allows CI/CD pipelines and development environments to set defaults without modifying command-line arguments. Also adds comprehensive documentation for all TUnit environment variables. Closes #4574 Co-Authored-By: Claude Opus 4.5 --- TUnit.Engine/Capabilities/BannerCapability.cs | 1 + docs/docs/reference/command-line-flags.md | 3 +- docs/docs/reference/environment-variables.md | 198 ++++++++++++++++++ docs/sidebars.ts | 1 + 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 docs/docs/reference/environment-variables.md diff --git a/TUnit.Engine/Capabilities/BannerCapability.cs b/TUnit.Engine/Capabilities/BannerCapability.cs index bdfaca4b64..e4d8615f35 100644 --- a/TUnit.Engine/Capabilities/BannerCapability.cs +++ b/TUnit.Engine/Capabilities/BannerCapability.cs @@ -23,6 +23,7 @@ internal class BannerCapability(IPlatformInformation platformInformation, IComma public Task GetBannerMessageAsync() { if (commandLineOptions.IsOptionSet(DisableLogoCommandProvider.DisableLogo) + || Environment.GetEnvironmentVariable("TUNIT_DISABLE_LOGO") is not null || loggerFactory.CreateLogger(nameof(BannerCapability)).IsEnabled(LogLevel.Information)) { return Task.FromResult(GetRuntimeDetails()); diff --git a/docs/docs/reference/command-line-flags.md b/docs/docs/reference/command-line-flags.md index f55f6aeebf..471c433eae 100644 --- a/docs/docs/reference/command-line-flags.md +++ b/docs/docs/reference/command-line-flags.md @@ -75,7 +75,8 @@ Please note that for the coverage and trx report, you need to install [additiona XML code coverage settings --disable-logo - Disables the TUnit logo when starting a test session + Disables the TUnit logo when starting a test session. + Can also be set via TUNIT_DISABLE_LOGO environment variable. --fail-fast Cancel the test run after the first test failure diff --git a/docs/docs/reference/environment-variables.md b/docs/docs/reference/environment-variables.md new file mode 100644 index 0000000000..f95896c650 --- /dev/null +++ b/docs/docs/reference/environment-variables.md @@ -0,0 +1,198 @@ +# Environment Variables + +TUnit supports configuration through environment variables, allowing you to set defaults without modifying command-line arguments. This is particularly useful for CI/CD pipelines and development environments. + +## TUnit-Specific Environment Variables + +### TUNIT_DISABLE_LOGO + +Disables the TUnit ASCII art logo when starting a test session. + +```bash +# Bash/Linux/macOS +export TUNIT_DISABLE_LOGO=true + +# PowerShell +$env:TUNIT_DISABLE_LOGO = "true" + +# Windows Command Prompt +set TUNIT_DISABLE_LOGO=true +``` + +**Equivalent to:** `--disable-logo` + +**Use case:** Reduces output noise in CI/CD logs or when using AI/LLM coding assistants that parse test output. + +### TUNIT_DISABLE_GITHUB_REPORTER + +Disables the automatic GitHub Actions test summary reporter. + +```bash +export TUNIT_DISABLE_GITHUB_REPORTER=true +``` + +**Use case:** When you want to use a custom reporting solution instead of the built-in GitHub Actions integration. + +### TUNIT_GITHUB_REPORTER_STYLE + +Controls the style of the GitHub Actions test reporter output. + +```bash +export TUNIT_GITHUB_REPORTER_STYLE=collapsible # default +export TUNIT_GITHUB_REPORTER_STYLE=full +``` + +**Values:** +- `collapsible` (default): Wraps detailed test results in expandable HTML blocks +- `full`: Displays all test details directly + +**Equivalent to:** `--github-reporter-style` + +### TUNIT_DISABLE_JUNIT_REPORTER + +Disables the JUnit XML reporter. + +```bash +export TUNIT_DISABLE_JUNIT_REPORTER=true +``` + +### TUNIT_ENABLE_JUNIT_REPORTER + +Explicitly enables the JUnit XML reporter. + +```bash +export TUNIT_ENABLE_JUNIT_REPORTER=true +``` + +### JUNIT_XML_OUTPUT_PATH + +Sets the output path for JUnit XML reports. + +```bash +export JUNIT_XML_OUTPUT_PATH=/path/to/output.xml +``` + +### TUNIT_MAX_PARALLEL_TESTS + +Sets the maximum number of tests that can run in parallel. + +```bash +export TUNIT_MAX_PARALLEL_TESTS=4 # Limit to 4 concurrent tests +export TUNIT_MAX_PARALLEL_TESTS=0 # Unlimited parallelism +``` + +**Equivalent to:** `--maximum-parallel-tests` + +**Note:** Command-line arguments take precedence over environment variables. + +## Microsoft Testing Platform Environment Variables + +These environment variables are provided by the underlying Microsoft Testing Platform: + +### TESTINGPLATFORM_TELEMETRY_OPTOUT + +Disables telemetry collection. + +```bash +export TESTINGPLATFORM_TELEMETRY_OPTOUT=1 +``` + +### TESTINGPLATFORM_UI_LANGUAGE + +Sets the language for platform messages and logs. + +```bash +export TESTINGPLATFORM_UI_LANGUAGE=en-us +``` + +## Platform-Level Flags + +Some command-line flags are handled by the Microsoft Testing Platform rather than TUnit directly. These flags currently do not have environment variable equivalents: + +- `--no-progress` - Disables progress reporting to screen +- `--no-ansi` - Disables ANSI escape characters + +### Workarounds for --no-progress + +While there's no environment variable for `--no-progress`, you can use these alternatives: + +**1. MSBuild Property (with `dotnet test`):** + +```xml + + --no-progress + +``` + +**2. Shell Wrapper:** + +```bash +#!/bin/bash +# run-tests.sh +./MyTestProject.exe --no-progress "$@" +``` + +**3. Direct Command Line:** + +```bash +./MyTestProject.exe --no-progress +``` + +## CI/CD Examples + +### GitHub Actions + +```yaml +- name: Run Tests + env: + TUNIT_DISABLE_LOGO: true + TUNIT_GITHUB_REPORTER_STYLE: collapsible + run: dotnet test +``` + +### Azure DevOps + +```yaml +- task: DotNetCoreCLI@2 + env: + TUNIT_DISABLE_LOGO: true + inputs: + command: 'test' +``` + +### GitLab CI + +```yaml +test: + variables: + TUNIT_DISABLE_LOGO: "true" + script: + - dotnet test +``` + +### Docker + +```dockerfile +ENV TUNIT_DISABLE_LOGO=true +ENV TUNIT_MAX_PARALLEL_TESTS=4 +``` + +## Priority Order + +When the same setting is configured in multiple places, TUnit follows this priority order (highest to lowest): + +1. **Command-line arguments** - Always take precedence +2. **Environment variables** - Applied when command-line argument is not provided +3. **Configuration files** - Applied as defaults + +## Summary Table + +| Environment Variable | Equivalent Flag | Description | +|---------------------|-----------------|-------------| +| `TUNIT_DISABLE_LOGO` | `--disable-logo` | Disables ASCII art logo | +| `TUNIT_GITHUB_REPORTER_STYLE` | `--github-reporter-style` | GitHub reporter style | +| `TUNIT_DISABLE_GITHUB_REPORTER` | - | Disables GitHub reporter | +| `TUNIT_DISABLE_JUNIT_REPORTER` | - | Disables JUnit reporter | +| `TUNIT_ENABLE_JUNIT_REPORTER` | - | Enables JUnit reporter | +| `JUNIT_XML_OUTPUT_PATH` | - | JUnit output path | +| `TUNIT_MAX_PARALLEL_TESTS` | `--maximum-parallel-tests` | Max parallel tests | diff --git a/docs/sidebars.ts b/docs/sidebars.ts index 19ab94b1b9..cc6cdb21b2 100644 --- a/docs/sidebars.ts +++ b/docs/sidebars.ts @@ -279,6 +279,7 @@ const sidebars: SidebarsConfig = { collapsed: true, items: [ 'reference/command-line-flags', + 'reference/environment-variables', 'reference/test-configuration', 'comparison/attributes', ],