FUnit 0.2.3
dotnet add package FUnit --version 0.2.3
NuGet\Install-Package FUnit -Version 0.2.3
<PackageReference Include="FUnit" Version="0.2.3" />
<PackageVersion Include="FUnit" Version="0.2.3" />
<PackageReference Include="FUnit" />
paket add FUnit --version 0.2.3
#r "nuget: FUnit, 0.2.3"
#:package FUnit@0.2.3
#addin nuget:?package=FUnit&version=0.2.3
#tool nuget:?package=FUnit&version=0.2.3
๐ฌ 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" (case-insensitive) 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 -y FUnit.Run -- -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;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- No dependencies.
-
net8.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 |
---|---|---|
0.2.3 | 370 | 9/16/2025 |
0.2.2 | 221 | 9/15/2025 |
0.2.1 | 220 | 9/15/2025 |
0.2.0 | 222 | 9/15/2025 |
0.2.0-rc.1 | 195 | 9/15/2025 |
0.1.2 | 183 | 9/14/2025 |
0.1.1 | 106 | 9/14/2025 |
0.1.0 | 105 | 9/14/2025 |
0.1.0-rc.3 | 99 | 9/14/2025 |