Storm Petrel Expected Baselines Rewriter
An incremental source generator that creates modified copies of unit and/or integration tests to update expected baselines in original tests, automating baseline creation and accelerating test development.
Challenge
The challenge arises when unit and/or integration tests fail due to code changes, such as adding new properties to baseline classes or fixing bugs. Manually fixing each expected baseline and running failed tests individually is time-consuming.
Approach
The approach involves using .NET Incremental Generators to generate modified “StormPetrel” test copies that can update expected baselines in original tests. Developers can run these tests to automatically overwrite baselines, then manually review the changes for accuracy, significantly reducing development time.
Description
The solution comprises several components developed as NuGet packages. The StormPetrel.Generator package incrementally generates modified “StormPetrel” test copies with embedded Storm Petrel context code. When executed, these tests capture actual baselines, convert them to C# code using the VarDump package or ObjectDumper.NET package, and overwrite the expected baselines in the original tests or other files.
Key Features
- Framework Support: Enhanced compatibility with leading test frameworks including XUnit, NUnit, and MSTest.
- Variable Pair Configuration: Flexible configuration options for actual/expected variable pairs, accommodating multiple sets.
- Customizable Algorithms: Provision for custom or configurable algorithms to generate or dump expected baselines, leveraging the Storm Petrel test execution context.
- Baseline Instantiation: Comprehensive support for expected baselines instantiated within the test method or sourced from external methods with variable arguments.
Result
The Storm Petrel .NET components streamline the process of updating expected baselines with minimal effort, expediting software development.