• Stars
    star
    221
  • Rank 179,773 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

.NET test logger that reports to GitHub Actions

GitHub Actions Test Logger

Made in Ukraine Build Coverage Version Downloads Discord Donate Fuck Russia

🟑 Project status: maintenance mode[?]

Icon

GitHub Actions Test Logger is a custom logger for dotnet test that integrates with GitHub Actions. When using this logger, failed tests are listed in job annotations and highlighted in code diffs. Additionally, this logger also generates a job summary that contains detailed information about the executed test run.

Terms of use[?]

By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all the following statements:

  • You condemn Russia and its military aggression against Ukraine
  • You recognize that Russia is an occupant that unlawfully invaded a sovereign state
  • You support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas
  • You reject false narratives perpetuated by Russian state propaganda

To learn more about the war and how you can help, click here. Glory to Ukraine! πŸ‡ΊπŸ‡¦

Install

  • πŸ“¦ NuGet: dotnet add package GitHubActionsTestLogger

Screenshots

annotations summary

Usage

To use GitHub Actions Test Logger, install it in your test project and modify your GitHub Actions workflow by adding --logger GitHubActions to dotnet test:

name: main
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install .NET
        uses: actions/setup-dotnet@v2
        with:
          dotnet-version: 6.0.x

      - name: Build & test
        run: dotnet test --configuration Release --logger GitHubActions

Warning: Ensure that your test project references the latest version of Microsoft.NET.Test.Sdk. Older versions of this package may not be compatible with the logger.

Warning: If you are using .NET SDK v2.2 or lower, you need to set the <CopyLocalLockFileAssemblies> property to true in your test project. Learn more.

Collecting source information

GitHub Actions Test Logger can leverage source information to link reported test results to the locations in the source code where the corresponding tests are defined. By default, dotnet test does not collect source information, so the logger relies on stack traces to extract it manually. This approach only works for failed tests, and even then may not always be fully accurate.

To instruct the runner to collect source information, add the RunConfiguration.CollectSourceInformation=true argument to the command as shown below:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      # ...

      - name: Build & test
        # Note that the space after the last double dash (--) is intentional
        run: >
          dotnet test
          --configuration Release
          --logger GitHubActions
          --
          RunConfiguration.CollectSourceInformation=true

Note: This option can also be enabled by setting the corresponding property in a .runsettings file instead. Learn more.

Customizing behavior

When running dotnet test, you can customize the logger's behavior by passing additional options:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      # ...

      - name: Build & test
        run: >
          dotnet test
          --configuration Release
          --logger "GitHubActions;annotations.titleFormat=@test;annotations.messageFormat=@error"

Custom annotation title

Use the annotations.titleFormat option to specify the annotation title format used for reporting test failures.

The following replacement tokens are available:

  • @test β€” replaced with the display name of the test
  • @traits.TRAIT_NAME β€” replaced with the value of the trait named TRAIT_NAME
  • @error β€” replaced with the error message
  • @trace β€” replaced with the stack trace
  • @framework β€” replaced with the target framework

Default: @test.

Examples:

  • @test β†’ MyTests.Test1
  • [@traits.Category] @test β†’ [UI Tests] MyTests.Test1
  • @test (@framework) β†’ MyTests.Test1 (.NETCoreApp,Version=v6.0)

Custom annotation message

Use the annotations.messageFormat option to specify the annotation message format used for reporting test failures. Supports the same replacement tokens as annotations.titleFormat.

Default: @error.

Examples:

  • @error β†’ AssertionException: Expected 'true' but found 'false'
  • @error\n@trace β†’ AssertionException: Expected 'true' but found 'false', followed by stacktrace on the next line

Include passed tests in summary

Use the summary.includePassedTests option to specify whether passed tests should be included in the summary. If you want to link passed tests to their corresponding source definitions, make sure to also enable source information collection.

Default: false.

Include skipped tests in summary

Use the summary.includeSkippedTests option to specify whether skipped tests should be included in the summary. If you want to link skipped tests to their corresponding source definitions, make sure to also enable source information collection.

Default: false.

More Repositories

1

DiscordChatExporter

Exports Discord chat logs to a file
C#
5,677
star
2

YoutubeDownloader

Downloads videos and playlists from YouTube
C#
4,837
star
3

CliWrap

Library for running command-line processes
C#
3,705
star
4

YoutubeExplode

Abstraction layer over YouTube's internal API
C#
2,473
star
5

LightBulb

Reduces eye strain by adjusting gamma based on the current time
C#
1,762
star
6

CliFx

Class-first framework for building command-line interfaces
C#
1,324
star
7

Onova

Unintrusive auto-update framework
C#
400
star
8

DotnetRuntimeBootstrapper

Bootstrapped framework-dependent deployment for .NET applications
C#
238
star
9

MiniRazor

Portable Razor compiler & code generator
C#
214
star
10

Gress

Progress reporting toolbox
C#
137
star
11

LtGt

Lightweight HTML processor
C#
117
star
12

OsuHelper

Beatmap suggester for osu!
C#
95
star
13

YoutubeExplode.Converter

Muxes and converts videos from YoutubeExplode
C#
87
star
14

SpellingUkraine

Learn the correct way to spell Ukrainian names in English
TypeScript
77
star
15

interview-questions

Collection of popular interview questions and their answers
66
star
16

Ressy

Resource editor for PE files
C#
43
star
17

Contextual

Implicit parameters via contexts
C#
40
star
18

JetBrainsDotnetDay2020

Presentation and code for my talk at JetBrains .NET Day Online 2020
F#
35
star
19

JsonExtensions

Extensions for System.Text.Json
C#
29
star
20

Extensions

My .NET extensions
C#
29
star
21

YoutubeMusicDownloader

Downloads Youtube videos and playlists as mp3 files
C#
26
star
22

Hallstatt

Low-ceremony testing framework optimized for modern C#
C#
25
star
23

Deorcify

Prevent your software from being used by terrorists
C#
22
star
24

WpfExtensions

My WPF extensions, converters and behaviors
C#
19
star
25

route-descriptor

Single source of truth for routing
TypeScript
17
star
26

Cogwheel

Library for managing application settings
C#
16
star
27

QuickJson

Simple JSON parser in a source-only package
C#
14
star
28

LockFile

Simplest lock file implementation
C#
13
star
29

Failsafe

Retry utility
C#
13
star
30

Tyrrrz.me

My personal website
TypeScript
13
star
31

.github

Assets shared between my repositories
12
star
32

FuncTestingInAspNetCoreExample

Example of doing functional testing with an ASP.NET Core application
C#
12
star
33

PolyShim

Polyfills for projects targeting older versions of .NET
C#
11
star
34

MyFlickList

Social cataloging app for movies and TV-shows
TypeScript
9
star
35

RaidTrend

Documenting air raid alerts across Ukraine
TypeScript
8
star
36

DotNetFest2019

My presentation and live demo project used during my talk at .NET Fest 2019
C#
8
star
37

WPSteamMarketExcerpt

Embeds Steam Market listings into WordPress pages
PHP
6
star
38

hip-cloud-test

will delete later
TypeScript
6
star
39

netfwdays-hipster-cloud

.NET fwdays'21 workshop
TypeScript
4
star
40

DiscordFonts

4
star
41

PrintForegroundWindow

Prints info about current foreground window
C#
4
star
42

Hashsum

Culture-invariant fluent checksum builder
C#
3
star
43

Tyrrrz

Profile readme
2
star
44

action-http-request

GitHub Action that sends an HTTP request
JavaScript
2
star
45

gatsby-plugin-clicky

Clicky web analytics integration for Gatsby
JavaScript
2
star
46

twitter-auth-cli

Quickly generate access token and secret for Twitter API
TypeScript
2
star
47

Scheddulit

Post scheduler and batcher for Reddit
TypeScript
1
star
48

OnovaTestRepo

Test repository used for Onova integration tests
1
star
49

AspNetCore.Mvc.Lightbox

Tag helper used to initialize Lightbox
C#
1
star
50

action-get-tag

GitHub Action that extracts current git tag
JavaScript
1
star
51

AspNetCore.Mvc.Clicky

Tag helper used to render Clicky activity tracker
C#
1
star
52

AspNetCore.Mvc.Disqus

Tag helper used to render Disqus threads
C#
1
star
53

BMAC-API-Cache

Caching layer for BuyMeACoffee API
TypeScript
1
star