Code Monkey home page Code Monkey logo

kurtmkurtm / liquidtestreports Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 7.0 553 KB

Generate Markdown test reports from TRX or JUnit files with the Cli or directly with the VSTest logger integration. Liquid Test Reports provides the ability to use built in templates, or provide your own liquid template.

Home Page: https://github.com/kurtmkurtm/LiquidTestReports/blob/master/README.md

License: BSD 2-Clause "Simplified" License

C# 99.52% PowerShell 0.48%
vstest test-reporting testing-tools test-automation dotnet markdown liquid-templates

liquidtestreports's Introduction

Fish logo

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

Package Version Description
LiquidTestReports.Cli NuGet Badge Command line tool to combine and convert TRX and JUnit tests reports into Markdown with Liquid template support
LiquidTestReports.Markdown NuGet Badge VS Test logger for generating test reports in Markdown format
LiquidTestReports.Custom NuGet Badge VS Test logger for generating reports from user provided liquid templates
LiquidTestReports.Core NuGet Badge Core library for creating custom VS Test loggers with liquid template support

Changelog

Latest:

2.0.0-beta.2

  • [All]
    • Add support for
      • .NET 7
      • .NET 8
    • Drop support for the following EOL frameworks
      • .NET Framework 4.5.1
      • .NET 5.0
      • .NET Core 3.1 (LTS)
      • .NET Core 2.1 (LTS)

1.4.3 beta

  • [Cli]
    • Add parameter support for the CLI based on the logger implementation
    • Fix issue where folder wasn't being used at file load time

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

Previous changes

LiquidTestReports.Cli (Beta):

NuGet Badge

Generate Markdown or Custom Test Reports from existing TRX files

Installation

dotnet tool install --global LiquidTestReports.Cli --version 2.0.0-beta.2

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 of JUnit. Defaults to Trx.
  • 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.
  • key=value; Optional key value pairs, only for custom template usage.

--parameters [parameters] Array of formatted key value strings for custom template usage, with configurations separated by a semicolon

--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 

Multiple Report inputs, grouping, and custom template usage

Removal

Global tool removal:

dotnet tool uninstall LiquidTestReports.Cli -g

LiquidTestReports.Markdown

NuGet Badge

The Markdown logger package is a ready to use implementation of the test logger that generates Markdown format reports.

Sample Report

How to use:

  1. Install the markdown logger to your test project by running the following command dotnet add package LiquidTestReports.Markdown

  2. Run the tests using the supplied logger dotnet test --logger "liquid.md"

  3. Report will be generated in the test results folder

See also: Testing .NET Core Apps with GitHub Actions

LiquidTestReports.Custom

NuGet Badge

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:

  1. Install the core logger to your test project either using the nuget or by running the following command

    dotnet add package LiquidTestReports.Custom

  2. Add a new text file to your test project, and set Copy to Output Directory as Copy 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 }}
  1. Run the tests using the supplied logger

    dotnet test --logger "liquid.custom;Template=TemplateExample.txt"

  2. 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

NuGet Badge

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:

  1. 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

liquidtestreports's People

Contributors

kurtmkurtm avatar nightowl888 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

liquidtestreports's Issues

Pass Rate 1000%

The Pass Rate on a simple .net6 project (only one nunit test) is reported as 1000% instead of 100%.
image

liquid --inputs "File=TestResults/*.trx" --output-file report.md

Is this a localization issue? e.g. 100.0% interpreted as 1000% (i'm on a german machine here)

Ability to specify report input with .*

Hi!

I have a solution with a large number of test projects, and we run those tests in blocks across multiple containers to increase the overall speed of test execution.

Ideally I would like to specify a report input that can bring all those reports together without having to specify each of the filenames, is it possible to do something like File=./buildartifacts/*.trx;Format=Trx ?

Missing code_file_path and line_number custom properties

Looking at the properties that can be used in custom templates I can see that the following properties in result_sets are supported:

code_file_path code file containing test
line_number - line number of the test

However when I try to use them the line_number is always zero and the code_file_path is always empty. The same is visible is the example output in the properties docs:


Duration: 00:00:00.0103816
Source: C:\github\LiquidTestReports\test\SampleProject\SampleProject.Tests.xUnit\bin\Debug\netcoreapp3.1\SampleProject.xUnit.dll
Executed Tests Count: 6
None Count: 0
Passed Count: 2
Failed Count: 3
Skipped Count: 1
Not Found Count: 0


Display: SampleProject.xUnit.TestServiceTests.TestTheory(expected: True)
Outcome: Passed
Error Message: 
Error Stack: 
ComputerName: DESKTOP-PNKUUD7
Duration: 00:00:00.0103816
StartTime: 18/08/2020 9:12:23 PM +10:00
EndTime: 18/08/2020 9:12:23 PM +10:00
Traits : 
Result Message Text: Running SampleProject.Tests.xUnit tests

Result Message Category: StdOutMsgs


Id: 8a3de9d4-fda6-4f04-f546-244cf03ac6c2
FQN: SampleProject.xUnit.TestServiceTests.TestTheory
Display Name: SampleProject.xUnit.TestServiceTests.TestTheory(expected: True)
Executor URI: executor://xunit/VsTestRunner2/netcoreapp
Source: C:\github\LiquidTestReports\test\SampleProject\SampleProject.Tests.xUnit\bin\Debug\netcoreapp3.1\SampleProject.xUnit.dll
Code File Path: 
Line Number: 0
Traits: 

Is this a known issue or am I missing something?

Framework update

Support will be dropped from the following EOL frameworks

  • .NET Framework 4.5.1
  • .NET 5.0
  • .NET Core 3.1 (LTS)
  • .NET Core 2.1 (LTS)

Adding support:

  • .NET 7
  • .NET 8

No changes:

  • .NET 6.0 (LTS)
  • .NET Standard 2.0

.NET Lifecycle

.NET Standard 2.0 Support?

I see that you changed from .NET Standard 2.0 to 2.1 in 1d99a30. Why was this done? I don't see any other commits that use functionality that doesn't exist in .NET Standard 2.0.

We'd like to use this library, but since we are targeting .NET Standard 2.0 (and since it doesn't require extra configuration, testing on .NET Core 2.1) it is not compatible with all of our targets. To prevent versioning conflicts, it has always been Microsoft's recommendation to target the lowest version you can when building shared libraries. On the .NET Standard page:

We recommend you target the lowest version of .NET Standard possible.

Of course, .NET Standard 1.x is pretty much moot since .NET Core 1.x went out of support, but .NET Standard 2.0 is still the "standard" way that most libraries use to eliminate multi-targeting.

Docs: how to access test traits

Looking at the properties that can be used in custom templates I can see that the list of traits is available:

traits - dictionary of traits on test case

However I had some difficulty on how to access the values for the traits. Looking at the example in the examples provided in the properties docs the usage and output are not useful as it tries to output the entire list of traits which results in a blank output.

By going through the code I found that the traits are represented by a list of TraitDrop objects and then I was able to output the traits by using something like:

{%- for trait in result.test_case.traits -%}
[{{ trait.Name }} : {{ trait.Value }}]</br>
{%- endfor -%}

Perhaps it's worth improving the example in the docs for how to access traits?

README: missing parameter when using LiquidTestReports.Custom NuGet

On the README, on the LiquidTestReports.Custom section, on step 3, it says:

  1. Run the tests using the supplied logger:
    dotnet test --logger "liquid.custom;TemplateExample.txt"

When I tried to use the above syntax with the following command:
dotnet test .\DotNet.Sdk.Extensions.sln --logger "liquid.custom;D:\Dev\edumserrano\dot-net-sdk-extensions\tests\liquid-test-logger-template.md"

I got this error on the output:

The Test Logger URI 'liquid.custom;D:\Dev\edumserrano\dot-net-sdk-extensions\tests\liquid-test-logger-template.md' is not valid. The Test Logger will be ignored.

Looking at the code I found that the correct syntax should be:
dotnet test .\DotNet.Sdk.Extensions.sln --logger "liquid.custom;Template=D:\Dev\edumserrano\dot-net-sdk-extensions\tests\liquid-test-logger-template.md"

Using the above command there are no errors and the report is created successfully.

Did I miss something or should the README be updated with the correct command?
Furthermore if you think it's worth it, I'd suggest improving the error message to give a better indication of what's wrong? People can go looking into the source code but if possible a better error message would have driven me to solve the problem quickly.

Wrong NuGet in readme?

How to use:

Install the markdown logger to your test project by running the following command dotnet add package LiquidTestReports.Core

Should be dotnet add package LiquidTestReports.Markdown ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.