### Install Xunit Logger Package
Source: https://context7.com/spekt/testlogger/llms.txt
Add the Xunit logger NuGet package to your test project.
```bash
# Add the Xunit logger to your test project
dotnet add package XunitXml.TestLogger
# Verify installation
dotnet list package | grep XunitXml
```
--------------------------------
### Install NUnit Logger Package
Source: https://context7.com/spekt/testlogger/llms.txt
Add the NUnit logger NuGet package to your test project.
```bash
# Add the NUnit logger to your test project
dotnet add package NUnitXml.TestLogger
# Verify installation
dotnet list package | grep NUnitXml
```
--------------------------------
### Install JUnit Logger Package
Source: https://context7.com/spekt/testlogger/llms.txt
Add the JUnit logger NuGet package to your test project.
```bash
# Add the JUnit logger to your test project
dotnet add package JUnitXml.TestLogger
# Verify installation
dotnet list package | grep JUnitXml
```
--------------------------------
### Sample JUnit XML output
Source: https://context7.com/spekt/testlogger/llms.txt
Example of the XML structure generated by the JUnit logger, compatible with Ant JUnit format.
```xml
at MyTests.UnitTest1.FailingTest() in /src/UnitTest1.cs:line 36
at MyTests.ParametrizedTests.TestData(Int32 x, String s) in /src/Tests.cs:line 241
Test Framework Informational Messages...Warning messages...
```
--------------------------------
### Example JUnit XML Structure for CircleCI
Source: https://github.com/spekt/testlogger/blob/master/docs/circleci-recommendation.md
This XML structure demonstrates how CircleCI interprets data within a `` element. Elements like `` and `` are displayed, but `` are not.
```xml
So can thisThis is also shown by CircleCISame for system-err tooCircleCI ignores data hereSame for system-err too
```
--------------------------------
### Configure console output via CLI
Source: https://github.com/spekt/testlogger/blob/master/src/JUnit.Xml.Package/README.md
Example command to disable console output capture when running tests.
```bash
dotnet test --logger:"junit;StoreConsoleOutput=false"
```
--------------------------------
### Package Project
Source: https://github.com/spekt/testlogger/blob/master/CLAUDE.md
Creates NuGet packages for the project.
```bash
dotnet pack
```
--------------------------------
### Run Full Build and Test (Linux/macOS)
Source: https://github.com/spekt/testlogger/blob/master/CLAUDE.md
Executes the full build and test suite for the project on Linux or macOS systems.
```shell
./build.sh
```
--------------------------------
### MTP support command line options
Source: https://github.com/spekt/testlogger/blob/master/src/NUnit.Xml.Package/README.md
Commands for using the logger with Microsoft.Testing.Platform.
```bash
> dotnet test -- --report-spekt-nunit --report-spekt-nunit-filename test-result.xml
```
```bash
> dotnet test -- --report-spekt-nunit "key1=value1;key2=value2"
```
--------------------------------
### Basic Xunit Test Logger Usage
Source: https://github.com/spekt/testlogger/blob/master/src/Xunit.Xml.Package/README.md
Use this command to enable the xunit logger for test projects. Test results will be generated in the `TestResults` directory.
```bash
> dotnet test --logger:xunit
```
--------------------------------
### Run Full Build and Test (Windows)
Source: https://github.com/spekt/testlogger/blob/master/CLAUDE.md
Executes the full build and test suite for the project on Windows systems.
```powershell
.\build.ps1
```
--------------------------------
### Configure StoreConsoleOutput
Source: https://context7.com/spekt/testlogger/llms.txt
Manage the capture and placement of console output within the test report.
```bash
# Default - capture all console output
dotnet test --logger:"junit;StoreConsoleOutput=true"
# Disable console output capture
dotnet test --logger:"junit;StoreConsoleOutput=false"
# Only at testsuite level
dotnet test --logger:"junit;StoreConsoleOutput=testsuite"
# Only at testcase level (v5.x+)
dotnet test --logger:"junit;StoreConsoleOutput=testcase"
```
--------------------------------
### NUnit test framework settings
Source: https://github.com/spekt/testlogger/blob/master/src/NUnit.Xml.Package/README.md
Advanced configuration for NUnit internal properties and output directory.
```bash
dotnet test --logger:nunit -- NUnit.ShowInternalProperties=true
```
```bash
dotnet test --logger:nunit -- NUnit.TestOutputXml=
```
--------------------------------
### Run tests with JSON logger
Source: https://github.com/spekt/testlogger/blob/master/README.md
Use this command to run tests and output results in JSON format. Ensure you are in the root of the repository.
```sh
# Run from root of repo
> dotnet test --no-build --logger:"json;LogFilePath=test-results.json" test/assets/Json.TestLogger.MSTest.NetCore.Tests/Json.TestLogger.MSTest.NetCore.Tests.csproj
```
--------------------------------
### Configure Jenkins with Runsettings
Source: https://context7.com/spekt/testlogger/llms.txt
Use a runsettings file for consistent JUnit logger configuration in Jenkins.
```xml
minimal{assembly}.{framework}.junit.xml
```
```groovy
// Jenkinsfile
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'dotnet test --settings _.runsettings'
}
post {
always {
junit allowEmptyResults: false, testResults: '**/TestResults/*.junit.xml'
}
}
}
}
}
```
--------------------------------
### Run tests with NUnit logger
Source: https://github.com/spekt/testlogger/blob/master/src/NUnit.Xml.Package/README.md
Basic command to execute tests and generate an NUnit XML report.
```bash
> dotnet test --logger:nunit
```
--------------------------------
### Project Structure
Source: https://github.com/spekt/testlogger/blob/master/CLAUDE.md
Illustrates the directory structure of the TestLogger project, showing the organization of core libraries, format-specific loggers, package projects, and test directories.
```tree
src/
├── TestLogger/ # Core library
├── JUnit.Xml.TestLogger/ # JUnit format implementation
├── NUnit.Xml.TestLogger/ # NUnit format implementation
├── Xunit.Xml.TestLogger/ # Xunit format implementation
└── *.Package/ # NuGet package projects
test/
├── *UnitTests/ # Unit tests for each logger
├── *AcceptanceTests/ # End-to-end tests
├── TestLogger.UnitTests/ # Core library tests
└── assets/ # Test project assets
```
--------------------------------
### Run Tests with MTP Xunit Logger
Source: https://context7.com/spekt/testlogger/llms.txt
Generate Xunit reports when using Microsoft.Testing.Platform v2.
```bash
# Basic MTP usage
dotnet test -- --report-spekt-xunit
# Specify output filename
dotnet test -- --report-spekt-xunit --report-spekt-xunit-filename test_result.xml
# Pass configuration options
dotnet test -- --report-spekt-xunit "key1=value1;key2=value2"
```
--------------------------------
### MTP Support with JUnit Logger
Source: https://github.com/spekt/testlogger/blob/master/src/JUnit.Xml.Package/README.md
Enable JUnit reporting for tests running with Microsoft.Testing.Platform (MTP). Use '--report-spekt-junit' to activate and specify the filename.
```bash
> dotnet test -- --report-spekt-junit --report-spekt-junit-filename test-result.xml
```
--------------------------------
### Run Multi-Target Test Project
Source: https://context7.com/spekt/testlogger/llms.txt
Execute tests for a multi-targeted project with comprehensive logging configuration.
```bash
# Full configuration example for GitLab/CircleCI
dotnet test MyTests.csproj \
--logger:"junit;LogFilePath=artifacts/{assembly}.{framework}.junit.xml;MethodFormat=Class;FailureBodyFormat=Verbose;StoreConsoleOutput=testcase;UseRelativeAttachmentPath=true"
```
--------------------------------
### Configure GitLab CI
Source: https://context7.com/spekt/testlogger/llms.txt
Collect JUnit test reports in GitLab CI with optimized display settings.
```yaml
# .gitlab-ci.yml
Test:
stage: Test
script:
- 'dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=..\artifacts\{assembly}-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"'
artifacts:
when: always
paths:
- .\artifacts\*test-result.xml
reports:
junit:
- .\artifacts\*test-result.xml
```
--------------------------------
### Specify Log File Path
Source: https://github.com/spekt/testlogger/wiki/Logger-Configuration
Use `LogFilePath` to provide an absolute path for the result file. The parent directory will be created if it doesn't exist. Tokens like `{assembly}` or `{framework}` can be used for dynamic naming.
```sh
# Use assembly name or framework token in test results file
> dotnet test --logger:"xunit;LogFilePath=/tmp/SampleTests/results/{assembly}.results.xml"
Results File: /tmp/SampleTests/results/SampleTests.results.xml
```
```sh
> dotnet test --logger:"xunit;LogFilePath=/tmp/SampleTests/results/{assembly}.{framework}.results.xml"
Results File: /tmp/SampleTests/results/SampleTests.NETCoreApp31.results.xml
```
--------------------------------
### MTP JUnit Logger with Configuration Arguments
Source: https://github.com/spekt/testlogger/blob/master/src/JUnit.Xml.Package/README.md
Pass custom key-value configuration arguments to the MTP JUnit logger. Ensure arguments are enclosed in quotes.
```bash
> dotnet test -- --report-spekt-junit "key1=value1;key2=value2"
```
--------------------------------
### MTP Xunit Test Logger with Configuration Arguments
Source: https://github.com/spekt/testlogger/blob/master/src/Xunit.Xml.Package/README.md
Pass custom configuration arguments to the Xunit Test Logger when using it with Microsoft.Testing.Platform (MTP). Arguments are provided as a semicolon-separated string.
```bash
> dotnet test -- --report-spekt-xunit "key1=value1;key2=value2"
```
--------------------------------
### Generate Xunit XML Report with VSTest
Source: https://context7.com/spekt/testlogger/llms.txt
Run tests with the Xunit logger to create an Xunit v2 format XML report.
```bash
# Basic usage - outputs to TestResults/TestResults.xml
dotnet test --logger:xunit
# Specify custom output path
dotnet test --logger:"xunit;LogFilePath=test_result.xml"
# Use token expansion for multi-targeted projects
dotnet test --logger:"xunit;LogFileName={assembly}.{framework}.xunit.xml"
```
--------------------------------
### Run Specific Acceptance Test
Source: https://github.com/spekt/testlogger/blob/master/CLAUDE.md
Executes a specific acceptance test for the TestLogger project.
```bash
dotnet test test/TestLogger.AcceptanceTests/TestLogger.AcceptanceTests.csproj
```
--------------------------------
### Specify NUnit log file path
Source: https://github.com/spekt/testlogger/blob/master/src/NUnit.Xml.Package/README.md
Command to define a custom output path for the generated XML report.
```bash
> dotnet test --logger:"nunit;LogFilePath=test-result.xml"
```
--------------------------------
### MTP Support with Xunit Test Logger
Source: https://github.com/spekt/testlogger/blob/master/src/Xunit.Xml.Package/README.md
Enable Xunit Test Logger for Microsoft.Testing.Platform (MTP) using specific command-line arguments. This allows for xunit v2 report generation within the MTP framework.
```bash
> dotnet test -- --report-spekt-xunit --report-spekt-xunit-filename test_result.xml
```
--------------------------------
### Customizing JUnit XML Contents
Source: https://github.com/spekt/testlogger/blob/master/src/JUnit.Xml.Package/README.md
Apply custom key-value pairs to tailor the JUnit XML output for specific CI/CD systems. Note that quotes are required and key names are case-sensitive.
```bash
> dotnet test --test-adapter-path:. --logger:"junit;key1=value1;key2=value2"
```
--------------------------------
### Run Tests with MTP NUnit Logger
Source: https://context7.com/spekt/testlogger/llms.txt
Generate NUnit reports when using Microsoft.Testing.Platform v2.
```bash
# Basic MTP usage
dotnet test -- --report-spekt-nunit
# Specify output filename
dotnet test -- --report-spekt-nunit --report-spekt-nunit-filename test-result.xml
# Pass configuration options
dotnet test -- --report-spekt-nunit "key1=value1;key2=value2"
```
--------------------------------
### Run Tests with MTP JUnit Logger
Source: https://context7.com/spekt/testlogger/llms.txt
Generate JUnit reports when using Microsoft.Testing.Platform v2.
```bash
# Basic MTP usage
dotnet test -- --report-spekt-junit
# Specify output filename
dotnet test -- --report-spekt-junit --report-spekt-junit-filename test-result.xml
# Pass configuration options
dotnet test -- --report-spekt-junit "MethodFormat=Class;FailureBodyFormat=Verbose"
```
--------------------------------
### Configure UseRelativeAttachmentPath
Source: https://context7.com/spekt/testlogger/llms.txt
Toggle between absolute and relative paths for test attachments.
```bash
# Default - absolute paths
dotnet test --logger:"junit;LogFilePath=/tmp/results/test.xml"
# Attachment path: /home/user/project/attachment.txt
# Relative paths enabled
dotnet test --logger:"junit;LogFilePath=/tmp/results/test.xml;UseRelativeAttachmentPath=true"
# Attachment path: ../home/user/project/attachment.txt (relative to test result file)
```
--------------------------------
### Basic JUnit Test Logger Usage
Source: https://github.com/spekt/testlogger/blob/master/src/JUnit.Xml.Package/README.md
Use this command to enable the JUnit logger for your .NET tests. Test results will be generated in the 'TestResults' directory.
```bash
> dotnet test --logger:junit
```
--------------------------------
### Logger Configuration Options
Source: https://github.com/spekt/testlogger/blob/master/src/JUnit.Xml.Package/README.md
Overview of available logger options for customizing test result output.
```APIDOC
## Logger Configuration Options
### Description
Configure the behavior of the test logger using command-line arguments, typically passed via `dotnet test --logger:"junit;Option=Value"`.
### Parameters
#### Query Parameters
- **LogFileName** (string) - Optional - Customize test result file name with {assembly} or {framework} tokens.
- **LogFilePath** (string) - Optional - Test result file full path.
- **UseRelativeAttachmentPath** (boolean) - Optional - Use attachment paths relative to test result file. Default: false.
- **MethodFormat** (string) - Optional - Alter test case name. Allowed: Default, Class, Full.
- **FailureBodyFormat** (string) - Optional - Control test result output. Allowed: Default, Verbose.
- **StoreConsoleOutput** (string) - Optional - Show or hide console output. Allowed: true, false, testsuite, testcase. Default: true.
```
--------------------------------
### Generate JUnit XML Report with VSTest
Source: https://context7.com/spekt/testlogger/llms.txt
Run tests with the JUnit logger to create a JUnit-compatible XML report.
```bash
# Basic usage - outputs to TestResults/TestResults.xml
dotnet test --logger:junit
# Specify custom output path
dotnet test --logger:"junit;LogFilePath=test-result.xml"
# Use token expansion for multi-targeted projects
dotnet test --logger:"junit;LogFileName={assembly}.{framework}.junit.xml"
# Example output location: TestResults/MyProject.NETCoreApp31.junit.xml
```
--------------------------------
### Generate NUnit XML Report with VSTest
Source: https://context7.com/spekt/testlogger/llms.txt
Run tests with the NUnit logger to create an NUnit v3 format XML report.
```bash
# Basic usage - outputs to TestResults/TestResults.xml
dotnet test --logger:nunit
# Specify custom output path
dotnet test --logger:"nunit;LogFilePath=test-result.xml"
# Use token expansion for multi-targeted projects
dotnet test --logger:"nunit;LogFileName={assembly}.{framework}.nunit.xml"
# Show internal properties like Description in the output
dotnet test --logger:nunit -- NUnit.ShowInternalProperties=true
```
--------------------------------
### Specify Xunit Test Logger File Path
Source: https://github.com/spekt/testlogger/blob/master/src/Xunit.Xml.Package/README.md
Customize the output file name and path for the xunit test results. The specified file will be generated in the same directory as the `test.csproj`.
```bash
> dotnet test --logger:"xunit;LogFilePath=test_result.xml"
```
--------------------------------
### Configure Jenkins with NUnit Logger
Source: https://context7.com/spekt/testlogger/llms.txt
Use the NUnit logger with the Jenkins NUnit plugin via runsettings.
```xml
minimal{assembly}.{framework}.nunit.xml
```
```groovy
// Jenkinsfile
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'dotnet test --settings _.runsettings'
}
post {
always {
nunit testResultsPattern: '**/TestResults/*.nunit.xml'
}
}
}
}
}
```
--------------------------------
### Run tests with multiple loggers
Source: https://context7.com/spekt/testlogger/llms.txt
Execute dotnet test with multiple logger configurations to generate different report formats simultaneously.
```bash
# Generate both JUnit and NUnit reports in a single test run
dotnet test --logger:"junit;LogFilePath=results/junit.xml" --logger:"nunit;LogFilePath=results/nunit.xml"
```
```bash
# Generate all three formats
dotnet test \
--logger:"junit;LogFilePath=results/junit.xml" \
--logger:"nunit;LogFilePath=results/nunit.xml" \
--logger:"xunit;LogFilePath=results/xunit.xml"
```
--------------------------------
### Specify Log File Name
Source: https://github.com/spekt/testlogger/wiki/Logger-Configuration
Use `LogFileName` to set the name of the output log file. Tokens like `{assembly}` or `{framework}` can be used for dynamic naming.
```sh
# Replace xunit with the relevant logger name
# > dotnet test --logger:";