FactCheck 1.0.0

dotnet add package FactCheck --version 1.0.0                
NuGet\Install-Package FactCheck -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FactCheck" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FactCheck --version 1.0.0                
#r "nuget: FactCheck, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FactCheck as a Cake Addin
#addin nuget:?package=FactCheck&version=1.0.0

// Install FactCheck as a Cake Tool
#tool nuget:?package=FactCheck&version=1.0.0                

FactCheck

FactCheck is a Roslyn analyzer that enforces human-readable unit test descriptions in .NET projects

Why

It makes your unit test reports look nicer.

In xUnit, the most popular .NET test framework, the attributes [Fact] and [Theory] accept the optional argument DisplayName:

[Fact(DisplayName = "System Under Test, when Condition is present, should exhibit Behavior")]
public void SystemUnderTest_WhenConditionIsPresent_ShouldExhibitBehavior()
{
    /* … */
}

This attribute sets the human-readable name for the fact or theory you're testing.

Most IDE's and test reporting tools honor this attribute and use it to report passed and failed tests.

It works in Visual Studio, Rider, Bamboo test parser, dotnet test CLI command, etc.:

$ dotnet test --list-tests

Microsoft (R) Test Execution Command Line Tool Version 17.3.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

The following Tests are available:
    XunitDisplayNameMismatchAnalyzer, when DisplayName does not match method name, should issue diagnostic
    XunitDisplayNameMissingAnalyzer, when DisplayName is provided on Fact, should not issue diagnostic
    XunitDisplayNameMissingAnalyzer, when qualified name is used, should not issue diagnostic
    XunitDisplayNameMissingAnalyzer, when attribute string is not trimmed, should not issue diagnostic
    XunitDisplayNameMissingAnalyzer, when DisplayName is not provided on Fact, should issue diagnostic
    XunitDisplayNameMissingAnalyzer, when DisplayName is not provided on Theory, should issue diagnostic
    SplitCode, when given code, should split(input: "lowercase", expectedOutput: ["lowercase"])
    SplitCode, when given code, should split(input: "Initcap", expectedOutput: ["Initcap"])
    SplitCode, when given code, should split(input: "UPPERCASE", expectedOutput: ["UPPERCASE"])
    …

What

FactCheck checks that DisplayName attribute is set on all fact and theory methods.

Missing DisplayName attribute

If the attribute is not set, it displays a hint and offers a fix to set the attribute from the method name:

alternate text is missing from this package README image

, or using the CLI:

dotnet format analyzers --diagnostics=FACTCHECK0001

Method name mismatch

If the method name does not match the human-readable name, FactCheck displays a hint and offers a fix to rename the method:

alternate text is missing from this package README image

, or using the CLI:

dotnet format analyzers --diagnostics=FACTCHECK0002

How

In your test project, run:

dotnet add package FactCheck
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 7,461 8/21/2022