Liquid Test Reports are logger extensions for the Visual Studio Test Platform that provide flexible test report generation using liquid templates. This project contains an extensible core for code based extension, a custom logger for providing your own templates without code, and a Markdown implementation.
Packages
Changelog
Latest:
1.3.2 beta
- [Cli]
- Add filename pattern matching support for CLI
1.2.1 beta
- [Cli]
- Add JUnit XML support
- Change template input to use file instead of content string
1.1.1 beta
- [Cli]
- Add new .NET Tool for report generation with TRX support
- Add new markdown report template
- [Core]
- Refactor drop model mapping
- Add TRX mapping
- Move template error logging from report generator into base test logger
LiquidTestReports.Cli (Beta):
Generate Markdown or Custom Test Reports from existing TRX files
Installation
dotnet tool install --global LiquidTestReports.Cli --version 1.2.1-beta
Usage
liquid [options]
Options:
--inputs [inputs] Array of formatted configuration strings for test report inputs, with configurations separated by a semicolon
- File=file-name; The path or glob pattern for input file/s
- Folder=folder-name; - Base directory for finding test files
- Format=report-format; Optional input report format, case insensitive, supported values are
Trx
ofJUnit
. Defaults toTrx
. - GroupTitle=group-title; Optional title to group reports under, test runs with the same group title will be merged.
- TestPrefix=test-prefix; Optional test suffix, if provided test origination for the provided report will have the suffix appended to its name.
--output-file [output-file] Path to save test report to.
--title [title] Optional overall report title displayed in default report template. Defaults to "Test Run"
--template [template] Optional user defined liquid template. Defaults to the multi report markdown template is used.
--version Show version information
-?, -h, --help Show help and usage information
Examples
JUnit to Markdown
liquid --inputs "File=xUnit-net461-junit-sample.xml;Format=JUnit" --output-file report.md
TRX to Markdown- Sample Output
liquid --inputs "File=xUnit-net461-sample.trx;Format=Trx" --output-file SingleInput.md
More Examples
File glob pattern relative to current directory
liquid --inputs "File=**/*sample.trx" --output-file report.md
File glob pattern using specific directory
liquid --inputs "File=**/*sample.trx;Folder=C:\MyTestFolder" --output-file report.md
Report from single input, with a custom title - Sample Output
liquid --inputs "File=xUnit-net461-sample.trx" --output-file CustomTitle.md --title "Test Run 2021"
Report from two inputs - Sample Output
liquid --inputs "File=xUnit-net461-sample.trx" "File=xUnit-netcoreapp3.1-sample.trx" --output-file TwoInputs.md
Grouped results - Sample Output Report with two inputs, and results grouped under the same section "Unit Tests":
liquid --inputs "File=xUnit-net461-sample.trx;GroupTitle=Unit Tests" "File=xUnit-netcoreapp3.1-sample.trx;GroupTitle=Unit Tests" --output-file GroupUnitTests.md
Grouped results with test name suffix - Sample Output
Report from two inputs, grouped under the same section "Unit Tests", with the tests from xUnit-netcoreapp3.1-sample.trx
having (3.1) appended to the test names
eg SampleProject.xUnit.TestServiceTests
becomes SampleProject.xUnit.TestServiceTests.PassingTest(3.1)
liquid --inputs "File=xUnit-net461-sample.trx;GroupTitle=Unit Tests" "File=xUnit-netcoreapp3.1-sample.trx;GroupTitle=Unit Tests;TestSuffix=(3.1)" --output-file GroupAndSuffix.md
Removal
Global tool removal:
dotnet tool uninstall LiquidTestReports.Cli -g
LiquidTestReports.Markdown
The Markdown logger package is a ready to use implementation of the test logger that generates Markdown format reports.
How to use:
-
Install the markdown logger to your test project by running the following command
dotnet add package LiquidTestReports.Markdown
-
Run the tests using the supplied logger
dotnet test --logger "liquid.md"
-
Report will be generated in the test results folder
See also: Testing .NET Core Apps with GitHub Actions
LiquidTestReports.Custom
The custom logger package allows you to create your own reports simply by passing the file path of the template to the test logger. The list of template properties are available here.
Sample Report (using example template below)
How to use:
-
Install the core logger to your test project either using the nuget or by running the following command
dotnet add package LiquidTestReports.Custom
-
Add a new text file to your test project, and set
Copy to Output Directory
asCopy always
, below is a starting sample template
Test Statistics:
None: {{ run.test_run_statistics.none_count }}
Passed: {{ run.test_run_statistics.passed_count }}
Failed: {{ run.test_run_statistics.failed_count }}
Skipped: {{ run.test_run_statistics.skipped_count }}
Not Found: {{ run.test_run_statistics.not_found_count }}
Total: {{ run.test_run_statistics.executed_tests_count }}
-
Run the tests using the supplied logger
dotnet test --logger "liquid.custom;TemplateExample.txt"
-
Report will be generated in the test results folder
For a more detailed example, take a look at included Markdown template.
More liquid template and syntax documentation is available on the Shopify Github.
LiquidTestReports.Core
The core project is utilised by the above two loggers and can be used to implement your own, however, this is yet to be documented. The custom and markdown implementations provide an guide of how to implement this.
How to install:
-
Install the core logger to your test project either using the nuget or by running the following command
dotnet add package LiquidTestReports.Core
Compatibility
.NET 4.5.1+ and .NET Core 3.0+
No additional configuration is required.
.NET Core 2.1 - 2.2
By default, the logger will not be copied to the output folder, and will not be discovered.
To use with these versions, include CopyLocalLockFileAssemblies
in your test project. This will copy the logger to your output folder.
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Note: this will also copy other NuGet dependencies into your output folder
.NET Core 2.0
Issues appear to be present in testing with .NET Core 2.0, as this target is no longer supported, it is recommended to update to supported version of .NET Core.
License
LiquidTestReports is under BSD 2-Clause License.
This library utilises the following libraries under the Apache 2.0 license
This library utilises the following libraries under the MIT License
- Microsoft - VSTest - https://github.com/microsoft/vstest/blob/master/LICENSE
- Spectre.Console - https://github.com/spectreconsole/spectre.console