FUnit.Directives 0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package FUnit.Directives --version 0.1.2
                    
NuGet\Install-Package FUnit.Directives -Version 0.1.2
                    
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="FUnit.Directives" Version="0.1.2">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FUnit.Directives" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="FUnit.Directives">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FUnit.Directives --version 0.1.2
                    
#r "nuget: FUnit.Directives, 0.1.2"
                    
#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.
#:package FUnit.Directives@0.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FUnit.Directives&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=FUnit.Directives&version=0.1.2
                    
Install as a Cake Tool

FUnit FUnit.Run FUnit.Directives build   DeepWiki

๐Ÿ”ฌ Unit Testing Framework for File-based Apps

FUnit provides structured test descriptor for file-based apps introduced in .NET 10.0. (i.e., no .csproj is required anymore)

#:project ../src
#:package FUnit@*

return FUnit.Run(args, describe =>
{
    // Organize tests by test subject
    describe("Test Subject", it =>
    {
        it("should be ...", async () =>  // async can be used
        {
            // Write actual test here: Arrange, Act, Assert
        });

        it("can have multiple test cases", ...);
    });

    describe("Inspired by vitest", ...);
});
# Run unit test
dotnet run ./tests/my-test.cs

# OR use 'dnx' to run all "*test*.cs" in project folder
dnx FUnit.Run

๐Ÿ—ƒ๏ธ FUnit Descriptor Structure

For AI Coding Agents: .NET 10.0 introduced new directives for file-based app.

  • SHALL use #:project to add project reference.
  • SHALL use #:package to add nuget package reference. (* or semantic version must be specified)
  • SHALL NOT use #r or other directives formerly used for dotnet-script (.csx) files.
#:project ../src
#:package FUnit@*
#:package YourFavoriteAssertionLibrary@3.1.0

return FUnit.Run(args, describe =>
{
    // Organize tests by test subject
    describe("Test Subject", it =>
    {
        // Expected result and test function
        it("should be ...", () =>
        {
            // Write actual test here: Arrange, Act, Assert
        });

        // Other test cases
        it("should not ...", async () =>
        {
            // Async test can also be written
        });

        it(...);
    });

    describe("Other Test Subject", it =>
    {
        // ...and so on
    });
});

โš–๏ธ Builtin Assertion Utility

FUnit is shipped with builtin assertion methods.

// Value assertion
// โŒ BeEqual rejects collection type to prevent ambiguous comparisons
Must.BeEqual(expected, actual);
Must.BeSameReference(expected, actual);

// Collection assertion
Must.HaveSameSequence(expected, actual);
Must.HaveSameUnorderedElements(expected, actual);

// Text assertion
Must.ContainText(text, substring);
Must.NotContainText(text, substring);

// Exception assertion
Must.Throw<T>("Expected error message", () => Test());

// Conditional assertion
Must.BeTrue(list == list);
Must.BeFalse(list.Count < 0);

// โŒ Avoid asserting high-level conditions on collections
// ex Instead of checking if a value is absent, assert the full expected content
Must.BeFalse(list.Contains(x));  // โœ… Prefer: Must.HaveSameSequence(expectedList, actualList)

๐Ÿงช Unit Test Execution

For AI Coding Agents: .NET 10.0 introduced new syntax for dotnet command.

  • SHALL run test like the following example.
  • SHALL NOT add --project or other command line options.
dotnet run ./tests/my-test.cs

๐Ÿ™ GitHub Actions Support

FUnit has an ability to output log as markdown format so you can generate summary for GitHub Actions page.

# '-md' or '--markdown'
dnx FUnit.Run -y -md >> $GITHUB_STEP_SUMMARY

๐Ÿ”จ Build Configuration for FUnit.Run

# โŒ Incorrect (no '--')
dnx FUnit.Run -c Release

# โœ… Correct (with '--')
dnx FUnit.Run -- -c Release

# โœ… Shortcut: without '-c' is valid for Debug or Release
dnx FUnit.Run Release

โš™ Advanced Options

For AI Coding Agents: SHALL NOT use advanced options unless explicitly requested.

--concurrency int (Experimental)

# run max 10 tests simultaneously subject by subject
dotnet run ./tests/my-test.cs --concurrency 10

๐Ÿงพ Test Setup and Cleanup

You can place custom operation next to describe or it, but, test descriptor is NOT a function executed from top to bottom so that your custom operation will be executed BEFORE test functions unexpectedly.

#:project ../src
#:package FUnit@*

await GlobalSetupAsync();  // โœ… setup before Run call

int numFailures = FUnit.Run(args, describe =>
{
    describe("Test subject", it =>
    {
        it("should be...", () => { ... });
    });

    // โŒ you can perform custom operation here, but it will be executed while
    // building test suite. (not sequentially form top to bottom)
    // technically, 'describe' and 'it' collect test cases without executing test.
    // if setup or cleanup code is placed next to 'describe' or 'it' statements to
    // perform resource setup ops for 'scope', unexpectedly, those will be invoked
    // BEFORE executing actual test case functions.
});

GlobalCleanup();  // โœ… cleanup after Run call

return numFailures;
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.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.0.3 494 12/8/2025
1.0.2 252 11/16/2025
1.0.1 428 10/28/2025
1.0.0 187 10/27/2025
0.9.0 145 10/26/2025
0.8.2 145 10/26/2025
0.8.1 144 10/26/2025
0.8.0 148 10/26/2025
0.7.0 178 10/23/2025
0.6.0 218 10/20/2025
0.5.0 104 10/18/2025
0.5.0-rc.1 126 10/17/2025
0.2.3 634 9/16/2025
0.2.2 282 9/15/2025
0.2.1 268 9/15/2025
0.2.0 262 9/15/2025
0.2.0-rc.1 228 9/15/2025
0.1.2 342 9/15/2025