Skip to content

Roslyn source generator that automatically adds sub classes of all test classes found in referenced test assemblies

License

Notifications You must be signed in to change notification settings

bjornhellander/TestInheritanceGenerator

Repository files navigation

InheritedTestsGenerator

Purpose

This source generator package generates test class "stubs" which inherit from test classes in a referenced test project. The typical use case is if you have test projects per version of some software component and you want all tests for the previous version to be executed for the next version as well. This is accomplished automatically by this package by generating a file for each found test class in the referenced test project and by adding inheritance to the original class.

Usage

Add a reference to this nuget package in the package you want to inherit test into and also reference the test project for the previous version.

It is possible to disable inheritance generation for specific test classes by adding an attribute called SkipInheritanceGenerationAttribute. This attribute can be added in the test project where it is needed, as long as it has that specific name. It is also available in a NuGet package called TestInheritanceGenerator.Annotations.

Supported test frameworks

The package has support for the following test frameworks:

  • MSTest
  • xUnit
  • NUnit

Analyzers

The following diagnostics are reported as guidance, if no tests are being generated:

Credits

This work is heavily inspired by a similar source generator implemented by Sam Harwell in StyleCop.Analyzers.

About

Roslyn source generator that automatically adds sub classes of all test classes found in referenced test assemblies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages