XFEExtension.NetCore.XUnit 3.0.0

dotnet add package XFEExtension.NetCore.XUnit --version 3.0.0
                    
NuGet\Install-Package XFEExtension.NetCore.XUnit -Version 3.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="XFEExtension.NetCore.XUnit" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XFEExtension.NetCore.XUnit" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="XFEExtension.NetCore.XUnit" />
                    
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 XFEExtension.NetCore.XUnit --version 3.0.0
                    
#r "nuget: XFEExtension.NetCore.XUnit, 3.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.
#:package XFEExtension.NetCore.XUnit@3.0.0
                    
#: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=XFEExtension.NetCore.XUnit&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=XFEExtension.NetCore.XUnit&version=3.0.0
                    
Install as a Cake Tool

XFEExtension.NetCore.XUnit

NuGet NuGet Downloads License: MIT .NET

📖 English | 简体中文

Description

XFEExtension.NetCore.XUnit is an XUnit-based testing framework that lets you run tests without writing a Main method. Simply annotate the classes or methods you want to test with the provided attributes.

Examples

Quick parameterless test cases (CTest & MTest)

[CTest]
//[CTest]
// Multiple test cases can be added
public class TestClass
{
    [MTest]
    //[MTest]
    //[MTest]
    // Multiple test cases can be added
    public void TestMethod()
    {
        Console.WriteLine("Hello World!");
    }
}

Test cases with parameters

[CTest]
public class TestClass
{
    [MTest(1, 2)]
    [MTest(2, 3)]
    [MTest(3, 4)]
    public void TestMethod(int a, int b)
    {
        Console.WriteLine(a + b);
    }
}

Assertions (via inheritance)

[CTest]
public class TestClass : XFECode
{
    [MTest(1, 2)]
    [MTest(2, 3)]
    public void TestMethod(int a, int b)
    {
        Assert(a + b == 3, "Not equal to 3");
    }
}

Assertions (without inheritance)

[CTest]
public class TestClass
{
    [MTest(1, 2)]
    [MTest(2, 3)]
    public void TestMethod(int a, int b)
    {
        XFECode.Assert(a + b == 3, "Not equal to 3");
    }
}

Verify return value equality (MRTest)

[CTest]
public class TestClass
{
    [MRTest(1, 2, 3)]
    [MRTest(2, 3, 5)]
    [MRTest(3, 4, 7)]
    public int TestMethod(int a, int b)
    {
        return a + b;
    }
}

Add descriptions to test cases (CNTest & MNTest)

[CTest("This is a test class")]
public class TestClass
{
    [MNTest("This is a test method")]
    public void TestMethod()
    {
        Console.WriteLine("Hello World!");
    }
}

Add description and return-value comparison together (MNRTest)

[CTest("This is a test class")]
public class TestClass
{
    [MNRTest("This is a test method", 1, 2, 3)]
    public int TestMethod(int a, int b)
    {
        return a + b;
    }
}

Set an initialization method for the test class (SetUp)

[CTest]
public class TestClass
{
    string initWord;

    [SetUp]
    public void SetUp()
    {
        initWord = "Hello World!";
    }

    [MTest]
    public void TestMethod()
    {
        Console.WriteLine(initWord);
    }
}

Test static methods directly (SMTest)

public class TestClass
{
    [SMTest]
    public static void TestMethod()
    {
        Console.WriteLine("Hello World!");
    }
}
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in 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
3.0.0 91 5/10/2026
2.1.1 107 3/25/2026
2.1.0 96 3/25/2026
2.0.5 140 1/24/2026
2.0.4 356 8/18/2024
2.0.3 278 4/16/2024
2.0.2 203 4/14/2024
2.0.1 238 3/20/2024
2.0.0 221 3/7/2024

版本更新至.NET 10.0,更新MD文档