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" />
<PackageReference Include="XFEExtension.NetCore.XUnit" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=XFEExtension.NetCore.XUnit&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XFEExtension.NetCore.XUnit
📖 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 | Versions 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.
-
net10.0
- XFEExtension.NetCore (>= 3.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
版本更新至.NET 10.0,更新MD文档