Skip to content

demaconsulting/TestResults

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

116 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

TestResults

GitHub forks GitHub stars GitHub contributors License Build Quality Gate Security NuGet

.NET library for TRX and JUnit test results

Overview

A .NET library for reading and writing test result files in multiple formats. Provides an in-memory model for test outcomes and results, supporting serialization to/from TRX (Visual Studio Test Results) and JUnit XML formats.

Features

  • ✨ Simple API - Intuitive and easy-to-use object model for test results
  • 🎯 Type-Safe - Strongly-typed C# classes for test outcomes and results
  • πŸͺΆ Lightweight - Zero runtime dependencies
  • πŸ”„ Multi-Target - Supports .NET Standard 2.0, .NET 8, 9, and 10
  • πŸ“¦ NuGet Ready - Easy integration via NuGet package
  • πŸ“Š Multiple Formats - Supports both TRX and JUnit XML formats
  • βœ… Compatible - Works with Visual Studio, Azure DevOps, and CI/CD systems
  • πŸ”’ Continuous Compliance - Compliance evidence generated automatically on every CI run, following the Continuous Compliance methodology

Installation

dotnet add package DemaConsulting.TestResults

Or via Package Manager Console:

Install-Package DemaConsulting.TestResults

Usage

using DemaConsulting.TestResults;
using DemaConsulting.TestResults.IO;

// Create a TestResults instance
var results = new TestResults { Name = "SomeTests" };

// Add test results
results.Results.Add(new TestResult
{
    Name = "Test1",
    ClassName = "SomeTestClass",
    CodeBase = "MyTestAssembly",
    Outcome = TestOutcome.Passed,
    Duration = TimeSpan.FromSeconds(1.5),
    StartTime = DateTime.UtcNow
});

results.Results.Add(new TestResult
{
    Name = "Test2",
    ClassName = "SomeTestClass",
    CodeBase = "MyTestAssembly",
    Outcome = TestOutcome.Failed,
    ErrorMessage = "Expected value to be 42 but was 0",
    ErrorStackTrace = "at SomeTestClass.Test2() in Test.cs:line 15"
});

// Save as TRX (Visual Studio format)
File.WriteAllText("results.trx", TrxSerializer.Serialize(results));

// Save as JUnit XML
File.WriteAllText("results.xml", JUnitSerializer.Serialize(results));

The library can automatically detect and convert between formats:

using DemaConsulting.TestResults.IO;

// Automatically detect and deserialize any supported format
var results = Serializer.Deserialize(File.ReadAllText("test-results.xml"));

// Convert JUnit to TRX
var junitResults = JUnitSerializer.Deserialize(File.ReadAllText("junit-results.xml"));
File.WriteAllText("converted.trx", TrxSerializer.Serialize(junitResults));

Test Outcomes

The library supports the following test outcomes via the TestOutcome enum:

Successful: Passed, PassedButRunAborted, Warning

Failure: Failed, Error, Timeout, Aborted

Skipped/Not Run: NotExecuted, NotRunnable, Pending

Other: Completed, Inconclusive, Disconnected, InProgress

Helper extension methods: IsPassed(), IsFailed(), IsExecuted()

Building

pwsh ./build.ps1

User Guide

The TestResults User Guide is available on the TestResults releases page.

Contributing

See CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License β€” see LICENSE.

Support

About

Dotnet Test Results Library

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors