TrxLib 0.0.3
dotnet add package TrxLib --version 0.0.3
NuGet\Install-Package TrxLib -Version 0.0.3
<PackageReference Include="TrxLib" Version="0.0.3" />
<PackageVersion Include="TrxLib" Version="0.0.3" />
<PackageReference Include="TrxLib" />
paket add TrxLib --version 0.0.3
#r "nuget: TrxLib, 0.0.3"
#:package TrxLib@0.0.3
#addin nuget:?package=TrxLib&version=0.0.3
#tool nuget:?package=TrxLib&version=0.0.3
TrxLib
TrxLib is a .NET library for parsing and analyzing TRX (Test Results XML) files generated by MSTest, VSTest, and other test runners in the .NET ecosystem. It provides a clean, easy-to-use API for extracting test results, metadata, and diagnostics information from TRX files.
Features
- Parse TRX files from Visual Studio, Azure DevOps, and other test runners
- Access detailed test results including pass/fail status, durations, and error messages
- Extract test metadata like namespaces, class names, and method names
- Process test run metadata including timing information, deployment settings, and run configuration
- Group test results by outcome (passed, failed, not executed, etc.)
Installation
TrxLib is available as a NuGet package: https://www.nuget.org/packages/TrxLib
Package Manager Console
Install-Package TrxLib
.NET CLI
dotnet add package TrxLib
Quick Start
// Parse a TRX file
TestResultSet results = TrxParser.Parse(new FileInfo("path/to/results.trx"));
// Get summary information
Console.WriteLine($"Total tests: {results.Count}");
Console.WriteLine($"Passed: {results.Passed.Count}");
Console.WriteLine($"Failed: {results.Failed.Count}");
Console.WriteLine($"Not executed: {results.NotExecuted.Count}");
// Get test timing information
Console.WriteLine($"Test run created: {results.CreatedTime}");
Console.WriteLine($"Test run started: {results.StartedTime}");
Console.WriteLine($"Test run completed: {results.CompletedTime}");
// Access individual test results
foreach (TestResult test in results.Failed)
{
Console.WriteLine($"Failed test: {test.FullyQualifiedTestName}");
Console.WriteLine($"Error message: {test.ErrorMessage}");
Console.WriteLine($"Stack trace: {test.StackTrace}");
Console.WriteLine($"Duration: {test.Duration}");
}
// Access test run metadata
string runId = results.OriginalTestRun?.Id;
string deploymentRoot = results.OriginalTestRun?.TestSettings?.Deployment?.RunDeploymentRoot;
Working with Test Results
Each TestResult object contains detailed information about a single test case:
TestResult test = results.FirstOrDefault(r => r.Outcome == TestOutcome.Failed);
// Basic test information
string testName = test.TestName; // The method name of the test
string className = test.ClassName; // The class containing the test
string namespace = test.Namespace; // The namespace of the test class
string fullName = test.FullyQualifiedTestName; // The fully qualified test name
// Test outcome and timing
TestOutcome outcome = test.Outcome; // Passed, Failed, NotExecuted, etc.
TimeSpan? duration = test.Duration; // How long the test took to run
DateTimeOffset? startTime = test.StartTime; // When the test started
DateTimeOffset? endTime = test.EndTime; // When the test finished
// For failed tests
string errorMessage = test.ErrorMessage; // The error message
string stackTrace = test.StackTrace; // The stack trace
// Test source information
FileInfo codebase = test.Codebase; // Path to the test assembly
DirectoryInfo projectDir = test.TestProjectDirectory; // Directory of the test project
Working with Test Result Sets
The TestResultSet class provides aggregated views of test results:
// Group tests by outcome
IReadOnlyCollection<TestResult> passedTests = results.Passed;
IReadOnlyCollection<TestResult> failedTests = results.Failed;
IReadOnlyCollection<TestResult> notExecutedTests = results.NotExecuted;
IReadOnlyCollection<TestResult> inconclusiveTests = results.Inconclusive;
IReadOnlyCollection<TestResult> timeoutTests = results.Timeout;
IReadOnlyCollection<TestResult> pendingTests = results.Pending;
// Filter and query results (using LINQ)
var longRunningTests = results.Where(r => r.Duration > TimeSpan.FromSeconds(1));
var testsByNamespace = results.GroupBy(r => r.Namespace);
var testsByClassName = results.GroupBy(r => r.ClassName);
// Test run metadata
string testRunName = results.TestRunName;
string testFilePath = results.TestFilePath;
License
Credits
Inspired by t-rex.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TrxLib:
| Package | Downloads |
|---|---|
|
VSTestPlaylistTools.TrxToPlaylistConverter
A .NET library for creating, parsing, and manipulating Visual Studio test playlist files. Supports advanced playlist building and integration with test runners. |
GitHub repositories
This package is not used by any popular GitHub repositories.