Bny.UnitTests 1.1.0

dotnet add package Bny.UnitTests --version 1.1.0
NuGet\Install-Package Bny.UnitTests -Version 1.1.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="Bny.UnitTests" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bny.UnitTests --version 1.1.0
#r "nuget: Bny.UnitTests, 1.1.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 Bny.UnitTests as a Cake Addin
#addin nuget:?package=Bny.UnitTests&version=1.1.0

// Install Bny.UnitTests as a Cake Tool
#tool nuget:?package=Bny.UnitTests&version=1.1.0

Bny.UnitTests

Bny.UnitTests is a library that makes unit testing in C# simpler.

In this repository

  • Bny.UnitTests - the library
  • Bny.UnitTests.Tests - unit tests
  • Bny.UnitTests.Examples - example usage

How to use

  • for detailed examples see Bny.UnitTests.Examples

Prepare your test classes

[UnitTest] // mark test classes with the [UnitTest] attribute
class TestSomething
{
    [UnitTest] // mark test functions with the [UnitTest] attribute
    static void Test_SomePart(Asserter a)
    { // all the test functions must have signature same as Action<Asserter>
        a.Assert(/* your assertion */);
        a.Assert(/* your next assertion */);
        // ...
    }
    
    [UnitTest]
    static void Test_OtherPart(Asserter a)
    {
        a.Assert(SomeHelperFunction(/* parameters */));
        // ...
    }
    
    static bool SomeHelperFunction(/* parameters */) { /* ... */ }
}

[UnitTest]
class TestSomethingElse { /* ... */ }

Run all the tests

Use the Tester.TestAll method to run all the tests in all the classes with the [UnitTest] attribute

Tester.TestAll();
Tester.TestAll parameters
  • logAmount: changes the amount of information written to the output
    • default value is LogAmount.Default
  • @out: the output writer
    • default value is null which means Console.Out (standard output stream)
  • formatted: determines whether the output is formatted with ANSI escape codes (colors)
    • default value is true

Example output

(Default parameters) image

How to get it

This library is available as a NuGet Package

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

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.1.0 320 11/27/2022
1.0.1 296 11/26/2022
1.0.0 307 11/26/2022