Unit Test Project
Generates a unit test project with placeholder unit tests.
Generate placeholder unit tests for .NET solutions.
Generates a unit test project with placeholder unit tests.
Supports multiple unit testing frameworks, together with their attributes and assertions.
Supports multiple options to handle existing unit tests.
Install
dotnet tool install --global KuBuCo.Alchemist
dotnet new tool-manifest
dotnet tool install KuBuCo.Alchemist
Usage
alchemist --solution ./mysolution.sln
alchemist --solution ./mysolution.sln --framework nunit
alchemist --solution ./mysolution.sln --regeneration.mode update
Use alchemist-demo to familiarise yourself with Alchemist.
Example
Source
namespace example;
public sealed class Calculator
{
public int Add(int left, int right)
{
return left + right;
}
}
Unit Test
using Xunit;
namespace UnitTests.Example;
public class CalculatorUnitTests
{
// [UnitTestID=6A1B2C3D4E5F6789]
[Fact(Skip = "Unit test not implemented.")]
public void Add_UnitTestPlaceholder()
{
Assert.True(false, "Scaffolded Unit Test");
}
}
Details
Generates a UnitTests/UnitTests.csproj, adds project references back to the examined projects and writes matching *UnitTests.cs files.
Adds the selected test framework together with shared dependencies.
Generates public placeholders named <SourceMethodName>_UnitTestPlaceholder with optional UnitTestID comments for reruns.
Targets .NET 8 although the examined solution can target newer versions as long as these are installed.
Reruns
Retains existing files and adds missing generated members.
Replaces matching generated methods and appends newly generated members.
Overwrites the target unit test file.
Labels
alchemist --solution ./mysolution.sln --regeneration.labels false
Labels can be disabled, but keeping UnitTestID comments is recommended for repeat generation.
// [UnitTestID=6A1B2C3D4E5F6789]
[Fact(Skip = "Unit test not implemented.")]
public void Add_UnitTestPlaceholder()
{
Assert.True(false, "Scaffolded Unit Test");
}
Limits