Skip to content

QuickOrBeDead/Labo.DotnetTestResultParser

Repository files navigation

dotnet-labodotnettestresultsparser

License NuGet NuGet

Travis Build Status Coverage Status CII Best Practices

.Net Core Test Result Parser Global Tool for NUnit, XUnit, MsTest

Installation

.NET Core 2.1 & higher

dotnet tool install --global dotnet-labodotnettestresultsparser

Usage

Help

$ dotnet labodotnettestresultsparser --help

dotnet-labodotnettestresultsparser

Usage: dotnet labodotnettestresultsparser [arguments] [options]

Arguments:
  path  The test result xml path.

Options:
  --version                     Show version information
  -?|-h|--help                  Show help information
  -f|--format                   Unit test result xml format. Allowed values are: NUnit, XUnit, MsTest. (Default: NUnit)
  -o|--output                   Output file to write results. (Default output is Console)
  -t|--template                 The output template. Allowed values are: Summary, TestResult. (Default: Summary)
  --fail-when-result-is-failed  Fails the program when the unit test result is 'Failed'.

Xml Formats

  • NUnit
  • XUnit
  • MsTest

Examples

Parse Test Reults Xml and Fail Program if Test Result is Failed

$ dotnet labodotnettestresultsparser <path> -f NUnit --fail-when-result-is-failed

Writes Only the Test Result Text (Passed | Failed) to the Output Text

$ dotnet labodotnettestresultsparser <path> -f NUnit -o <output.txt> -t TestResult

Output:

$ Passed

Writes Only the Test Result Text (Passed | Failed) for Multiple Unit Test Result Xmls to the Output Text

$ dotnet labodotnettestresultsparser "/testresults/*.unittest.xml" -f NUnit -o <output.txt> -t TestResult

Output:

$ Passed

Bash script that checks Unit Test Results for multiple xmls

dotnet labodotnettestresultsparser "/testresults/*.unittest.xml" -f NUnit -o /testresults/result.txt -t TestResult

if [ ! -f /testresults/result.txt ]; then
    echo "Test Result File not found!"
    exit 1
fi

result=$(head -n 1 /testresults/result.txt)

if [ "$result" == "Failed" ]
then
    echo "Unit Tests Failed!"
    exit 1
else
   echo "Unit Tests Passed!"
fi

Output:

$ Unit Tests Passed!

Build

git clone https://github.com/QuickOrBeDead/Labo.DotnetTestResultParser.git
cd Labo.DotnetTestResultParser/src/Labo.DotnetTestResultParser
dotnet pack -c release -o nupkg

Output is located at src/Labo.DotnetTestResultParser/nupkg

Uninstall

dotnet tool uninstall -g dotnet-labodotnettestresultsparser

Useful Links