CI/CD Reporting
TUnit provides built-in integration with continuous integration and deployment platforms, automatically detecting and adapting to various CI environments.
GitHub Actions Reporterâ
When running in GitHub Actions, TUnit automatically generates a test summary that appears in the workflow run summary. This feature activates when the GITHUB_ACTIONS environment variable is detected.
Automatic Detectionâ
The GitHub reporter automatically enables when:
- The
GITHUB_ACTIONSenvironment variable is set - The
GITHUB_STEP_SUMMARYenvironment variable points to a valid file
No additional configuration is required for basic functionality.
Reporter Stylesâ
TUnit's GitHub reporter supports two output styles:
Collapsible Style (Default)â
The collapsible style provides a clean, concise summary with expandable details:
### TestAssembly (.NET 9.0)
| Test Count | Status |
| --- | --- |
| 95 | Passed |
| 5 | Failed |
<details>
<summary>đ Test Details (click to expand)</summary>
### Details
| Test | Status | Details | Duration |
| --- | --- | --- | --- |
| MyTest.ShouldFail | Failed | Expected: true, Actual: false | 123ms |
| ... | ... | ... | ... |
</details>
This is the default style as of TUnit v1.0.0, designed to:
- Keep workflow summaries clean and navigable
- Allow quick overview of test results
- Provide full details on demand
- Work well with large test suites
Full Style (Legacy)â
The full style displays all test details directly in the summary:
### TestAssembly (.NET 9.0)
| Test Count | Status |
| --- | --- |
| 95 | Passed |
| 5 | Failed |
### Details
| Test | Status | Details | Duration |
| --- | --- | --- | --- |
| MyTest.ShouldFail | Failed | Expected: true, Actual: false | 123ms |
| ... | ... | ... | ... |
Configuration Optionsâ
You can control the GitHub reporter style using either command-line arguments or environment variables:
Command Lineâ
# Use collapsible style (default)
dotnet test -- --github-reporter-style collapsible
# Use full style (legacy behavior)
dotnet test -- --github-reporter-style full
Environment Variableâ
# Set reporter style via environment variable
export TUNIT_GITHUB_REPORTER_STYLE=collapsible # or 'full'
dotnet test
# In GitHub Actions workflow
- name: Run Tests
env:
TUNIT_GITHUB_REPORTER_STYLE: collapsible
run: dotnet test
GitHub Actions Workflow Exampleâ
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'
- name: Run Tests with Collapsible Reporter
run: dotnet test --logger "console;verbosity=normal"
# GitHub reporter auto-detects and uses collapsible style by default
- name: Run Tests with Full Reporter
run: dotnet test -- --github-reporter-style full
# Explicitly use full style for all details
Disabling the GitHub Reporterâ
If you need to disable the GitHub reporter entirely:
Via Environment Variableâ
export TUNIT_DISABLE_GITHUB_REPORTER=true
# or
export DISABLE_GITHUB_REPORTER=true
# In GitHub Actions workflow
- name: Run Tests Without GitHub Reporter
env:
TUNIT_DISABLE_GITHUB_REPORTER: true
run: dotnet test
File Size Limitationsâ
The GitHub reporter respects GitHub's file size limits:
- Maximum summary file size: 1MB
- If the output would exceed this limit, the reporter will skip writing to prevent errors
- Consider using the collapsible style for large test suites to reduce summary size
Filtering Test Outputâ
When using the GitHub reporter, only non-passing tests are included in the details section:
- Failed tests
- Skipped tests
- Timed out tests
- Cancelled tests
- Tests that never completed (in progress)
Passed tests are counted but not listed in details to keep the summary focused on actionable items.
Other CI Platformsâ
While TUnit currently provides specialized support for GitHub Actions, it works with all CI/CD platforms through standard test output formats:
Azure DevOpsâ
Use TRX reporting for Azure DevOps integration:
dotnet test --report-trx --report-trx-filename TestResults.trx
Jenkinsâ
Jenkins can consume various test output formats:
# Generate TRX report for Jenkins
dotnet test --report-trx
# Or use console output with appropriate verbosity
dotnet test --logger "console;verbosity=detailed"
GitLab CIâ
GitLab can parse test results in various formats:
test:
script:
- dotnet test --report-trx
artifacts:
reports:
junit:
- TestResults/*.trx
Environment Detectionâ
TUnit automatically detects common CI environments through environment variables:
| Platform | Detection Variables |
|---|---|
| GitHub Actions | GITHUB_ACTIONS |
| Azure DevOps | AZURE_PIPELINES |
| Jenkins | JENKINS_URL |
| GitLab CI | GITLAB_CI |
| CircleCI | CIRCLECI |
| Travis CI | TRAVIS |
| AppVeyor | APPVEYOR |
| TeamCity | TEAMCITY_VERSION |
| Generic CI | CI, CONTINUOUS_INTEGRATION |
This detection helps TUnit optimize its behavior for each platform.
Best Practicesâ
- Use Collapsible Style for Large Test Suites: The default collapsible style keeps summaries manageable
- Filter Tests in CI: Use
--treenode-filterto run specific test subsets in different CI jobs - Set Appropriate Timeouts: Use
--timeoutto prevent hanging builds - Enable Fail-Fast for Quick Feedback: Use
--fail-fastin PR validation builds - Customize Verbosity: Adjust
--outputbased on your debugging needs
Troubleshootingâ
GitHub Reporter Not Workingâ
If the GitHub reporter isn't generating summaries:
-
Check Environment Variables:
echo $GITHUB_ACTIONS # Should output 'true'
echo $GITHUB_STEP_SUMMARY # Should point to a file -
Verify Not Disabled:
# Ensure these are not set
echo $TUNIT_DISABLE_GITHUB_REPORTER
echo $DISABLE_GITHUB_REPORTER -
Check File Permissions: Ensure the process can write to
GITHUB_STEP_SUMMARYfile -
Review Test Output: Run with
--diagnosticto see detailed logs
Summary Not Appearingâ
If tests run but no summary appears:
- Check if all tests passed (summaries may be minimal for all-passing runs)
- Verify the workflow has completed (summaries appear after job completion)
- Check the "Summary" section of the GitHub Actions run page
Large Summary Filesâ
If you encounter file size issues:
- Switch to collapsible style:
--github-reporter-style collapsible - Filter tests to reduce output:
--treenode-filter "critical-tests" - Run tests in separate jobs with focused test subsets