Testing
Version 6.1.0
In this article
This article describes how PDFsharp and MigraDoc unit tests cover the different builds and frameworks.
Further it describes how to use the provided test script to execute the tests for all available environments.
It is not necessary to read this if you just want to use PDFsharp.
Builds and Frameworks
PDFsharp and MigraDoc include test projects for Core, GDI+, and WPF builds. All of these test projects target .NET 6 and .NET Framework 4.7.2. This way most unit tests can be run for each build targeting one of the frameworks. All those tests can be executed on Windows machines. On Linux machines all tests for the Core build targeting .NET 6 shall be executed successfully. These tests can also be run in WSL.
We use Ubuntu 22.04 as WSL to execute the tests for the Core build targeting .NET 6 on Linux. The Core build targeting .NET 6 is the recommended way of using PDFsharp and MigraDOc on Linux. Therefore, we don't ensure .NET Framework 4.7.2 tests are running successfully in Linux using Mono.
The test script
The PDFsharp repository provides a test script run-test.ps1
for running all PDFsharp and MigraDoc tests in all available environments.
These environments depend on the system where the script is executed:
- Windows System without WSL
All Core, GDI+, and WPF tests are executed targeting .NET 6 and .NET Framework 4.7.2 on the local Windows system. - Windows System with WSL
All Core, GDI+, and WPF tests are executed targeting .NET 6 and .NET Framework 4.7.2 on the local Windows system.
Additionally all Core tests are executed targeting .NET 6 on the hosted WSL. - Linux System or WSL
All Core tests are executed targeting .NET 6 on the Linux system or WSL.
Running the test script
After building the PDFsharp solution in Debug configuration go to the root folder of the solution and execute
.\dev\run-test.ps1
Running all tests
Running all tests takes more than six minutes on our development machines. By default, some time consuming tests are skipped so we get the tests run in less than one minute.
To activate all tests, set the environment variable PDFsharpTests to any non-empty value. You can easily set the environment variable in a console window before running the test script or before starting PDFsharp.sln from this console window. An environment variable set in such a console window applies to this console and to all processes started from this console.