Skip to content

Instantly share code, notes, and snippets.

@samuell
Created March 4, 2019 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuell/d5b5dc9d76d1d9314b39ea75f4b86edb to your computer and use it in GitHub Desktop.
Save samuell/d5b5dc9d76d1d9314b39ea75f4b86edb to your computer and use it in GitHub Desktop.
#!/bin/bash
# ---------------------------------------------------------------------
# Generate test coverage for .Net core 2 projects.
# ---------------------------------------------------------------------
# Author: Samuel Lampa
#
# This script is supposed to be run in a Windows bash-environment such
# as MSYS2 (See this post for a guide on how to set up one:
# https://bionics.it/posts/linux-like-non-wsl-terminal-env-on-windows)
#
# Requires that you first install:
# - CoverLet https://github.com/tonerdo/coverlet (NuGet
# - ReportGenerator https://github.com/danielpalme/ReportGenerator
# ... and make sure they are available in your $PATH variable.
# ---------------------------------------------------------------------
dotnet build
coverlet ./bin/Debug/netcoreapp2.1/[YourPackage].dll --target dotnet --targetargs "test --no-build" --format opencover;
/c/Users/$USER/.nuget/packages/reportgenerator/4.0.14/tools/net47/ReportGenerator.exe "-reports:coverage.opencover.xml" "-targetdir:covreport";
echo "Now trying to open the report in the Brave browser (if it doesn't work, you probably don't have Brave installed)";
/c/Program\ Files\ \(x86\)/BraveSoftware/Brave-Browser/Application/brave.exe covreport/index.htm;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment