Generate a markdown summary of your C# unit tests via a simple C# script (CSX script executed via dotnet script or CSI.exe).
- currently supports NUnit based tests
test-doc is a CSX script (C# script). There are two main ways to execute a CSX script:
- via dotnet script (.NET Core 6 or 7)
- via CSI.exe (installed with Microsoft Visual Studio)
- Check that .NET Core 6 or 7 is installed:
dotnet --version
- Install the 'script' tool of dotnet
dotnet tool install -g dotnet-script
-
Build your unit tests and note the path to the assembly (the DLL file).
-
Open a command prompt.
-
CD to this directory
-
Execute the C# script via
dotnet script
:
dotnet script test-doc.csx <path to the unit tests DLL>
This outputs a summary of all unit tests in markdown format.
-
Build your unit tests and note the path to the assembly (the DLL file).
-
Open a
Developer Command Prompt
. This is installed with Microsoft Visual Studio and you can search for it viaWindows-Key + Q
. OR if you have .NET Core 5 or 6 installed thencsi
may be available. -
CD to this directory
-
Execute the C# script via CSI:
csi test-doc.csx <path to the unit tests DLL>
This outputs a summary of all unit tests in markdown format.
# 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
The C# script requires tooling to execute the CSX script.
There are 2 options:
- [recommended] dotnet core and dotnet script
OR
- CSI to execute.
This is installed as part of Microsoft Visual Studio.
Tested with:
- dotnet script (dotnet version 6.0.400)
- Microsoft (R) Visual C# Interactive Compiler version 4.3.0-3.22401.3
The version of the tool (dotnet script
or else CSI.exe
) determines which .NET framework will be used to execute. This limits which .NET assemblies (DLL files) can be loaded for analysis.
So for example, if the CSI tool is .NET Core based, then it might not be able to load Windows specific .NET assemblies. In that case, it is beter to use dotnet script
.