TrxLib 0.0.2
dotnet add package TrxLib --version 0.0.2
NuGet\Install-Package TrxLib -Version 0.0.2
<PackageReference Include="TrxLib" Version="0.0.2" />
<PackageVersion Include="TrxLib" Version="0.0.2" />
<PackageReference Include="TrxLib" />
paket add TrxLib --version 0.0.2
#r "nuget: TrxLib, 0.0.2"
#:package TrxLib@0.0.2
#addin nuget:?package=TrxLib&version=0.0.2
#tool nuget:?package=TrxLib&version=0.0.2
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
NuGet Package ManagerInstall-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 | net8.0 is compatible. 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. |
-
net8.0
- 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.