Generate a markdown summary of your C# unit tests via a simple C# script (CSX script executed via dotnet script or CSI.exe)

Generate a markdown summary of your C# unit tests via a simple C# script (CSX script executed via dotnet script or CSI.exe)


For more complex codebases, it can be handy to have an overview of unit tests.

A markdown file is text based and easily searchable.

When automatically generated, it is easy to keep up to date.

This can be acheived by using the Reflection facility of .NET.
The reflection API can be accessed in any .NET language.
Scripting can be implemented via a .NET compatible scripting language such as Powershell or C# script.

As a C# developer I find C# scripting a simple way to code such scripts.

A C# script is a file named with the .CSX extension.

The code is very much familiar to any C# developer, with some special properties:

- code can be written without any enclosing namespace
- the Console.Writeline() method is available at top level, without the Console specifer:

Writeline("Hello world");

test-doc - a C# script to summarize unit tests

Generate a markdown summary of your C# unit tests via a simple C# script (CSX script executed via dotnet script or CSI.exe).

Usage:

dotnet script test-doc.csx <path to the unit tests DLL>



Example output:

# Tests in MyCompany.Project1.MyApp.CoreTests

## Test class NumberParsingTests
 - It_should_parse_a_number
 - It_should_not_parse_a_date

## Test class InterestCalculator
 - It_should_calculate_interest_for_one_year_at_10_percent
 - It_should_calculate_interest_for_5_years_at_15_percent


References


- For more details about C# scripts and dotnet script, see the official dotnet script github repository.


Comments