csharp-tunit by github/awesome-copilot
npx skills add https://github.com/github/awesome-copilot --skill csharp-tunit你的目标是帮助我使用 TUnit 编写有效的单元测试,涵盖标准和数据驱动测试方法。
[项目名称].TestsCalculator 创建 CalculatorTests)dotnet test 来运行测试[Test] 属性(而不是像 xUnit 那样使用 [Fact])方法名_场景_预期行为 模式命名测试广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
[Before(Test)] 用于设置,[After(Test)] 用于清理[Before(Class)] 和 [After(Class)] 用于类中测试之间的共享上下文[Before(Assembly)] 和 [After(Assembly)] 用于跨测试类的共享上下文[Before(TestSession)] 和 [After(TestSession)]await Assert.That()[DependsOn] 属性)[Arguments] 属性进行内联测试数据(相当于 xUnit 的 [InlineData])[MethodData] 进行基于方法的测试数据(相当于 xUnit 的 [MemberData])[ClassData] 进行基于类的测试数据ITestDataSource 创建自定义数据源[Arguments] 属性可以应用于同一个测试方法await Assert.That(value).IsEqualTo(expected) 进行值相等性断言await Assert.That(value).IsSameReferenceAs(expected) 进行引用相等性断言await Assert.That(value).IsTrue() 或 await Assert.That(value).IsFalse() 进行布尔条件断言await Assert.That(collection).Contains(item) 或 await Assert.That(collection).DoesNotContain(item) 进行集合断言await Assert.That(value).Matches(pattern) 进行正则表达式模式匹配断言await Assert.That(action).Throws<TException>() 或 await Assert.That(asyncAction).ThrowsAsync<TException>() 来测试异常.And 操作符链接断言:await Assert.That(value).IsNotNull().And.IsEqualTo(expected).Or 操作符处理替代条件:await Assert.That(value).IsEqualTo(1).Or.IsEqualTo(2).Within(tolerance) 进行带容差的 DateTime 和数值比较[Repeat(n)] 重复测试多次[Retry(n)] 在失败时自动重试[ParallelLimit<T>] 控制并行执行限制[Skip("reason")] 有条件地跳过测试[DependsOn(nameof(OtherTest))] 创建测试依赖关系[Timeout(milliseconds)] 设置测试超时[Category("CategoryName")] 进行测试分类[DisplayName("Custom Test Name")] 设置自定义测试名称TestContext 进行测试诊断和信息获取[WindowsOnly] 用于平台特定测试[NotInParallel] 为特定测试禁用并行执行[ParallelLimit<T>] 来控制并发性[Repeat(n)] 与 [ParallelLimit<T>] 结合使用以进行负载测试场景[Fact] 替换为 [Test][Theory] 替换为 [Test],并使用 [Arguments] 提供数据[InlineData] 替换为 [Arguments][MemberData] 替换为 [MethodData]Assert.Equal 替换为 await Assert.That(actual).IsEqualTo(expected)Assert.True 替换为 await Assert.That(condition).IsTrue()Assert.Throws<T> 替换为 await Assert.That(action).Throws<T>()[Before(Test)]/[After(Test)]IClassFixture<T> 替换为 [Before(Class)]/[After(Class)]为什么选择 TUnit 而不是 xUnit?
TUnit 提供了现代化、快速且灵活的测试体验,具备 xUnit 所没有的高级功能,例如异步断言、更精细的生命周期钩子以及改进的数据驱动测试能力。TUnit 的流畅断言提供了更清晰、更具表现力的测试验证,使其特别适合复杂的 .NET 项目。
每周安装量
7.3K
代码仓库
GitHub 星标数
27.0K
首次出现
2026年2月25日
安全审计
安装于
codex7.3K
gemini-cli7.3K
opencode7.2K
cursor7.2K
github-copilot7.2K
kimi-cli7.2K
Your goal is to help me write effective unit tests with TUnit, covering both standard and data-driven testing approaches.
[ProjectName].TestsCalculatorTests for Calculator)dotnet test for running tests[Test] attribute for test methods (not [Fact] like xUnit)MethodName_Scenario_ExpectedBehavior[Before(Test)] for setup and [After(Test)] for teardown[Before(Class)] and [After(Class)] for shared context between tests in a class[Before(Assembly)] and [After(Assembly)] for shared context across test classes[Before(TestSession)] and [After(TestSession)]await Assert.That()[DependsOn] attribute if needed)[Arguments] attribute for inline test data (equivalent to xUnit's [InlineData])[MethodData] for method-based test data (equivalent to xUnit's [MemberData])[ClassData] for class-based test dataITestDataSource[Arguments] attributes can be applied to the same test methodawait Assert.That(value).IsEqualTo(expected) for value equalityawait Assert.That(value).IsSameReferenceAs(expected) for reference equalityawait Assert.That(value).IsTrue() or await Assert.That(value).IsFalse() for boolean conditionsawait Assert.That(collection).Contains(item) or await Assert.That(collection).DoesNotContain(item) for collectionsawait Assert.That(value).Matches(pattern) for regex pattern matchingawait Assert.That(action).Throws<TException>() or await Assert.That(asyncAction).ThrowsAsync<TException>() to test exceptions[Repeat(n)] to repeat tests multiple times[Retry(n)] for automatic retry on failure[ParallelLimit<T>] to control parallel execution limits[Skip("reason")] to skip tests conditionally[DependsOn(nameof(OtherTest))] to create test dependencies[Timeout(milliseconds)] to set test timeouts[Category("CategoryName")] for test categorization[DisplayName("Custom Test Name")] for custom test namesTestContext for test diagnostics and information[WindowsOnly] for platform-specific tests[NotInParallel] to disable parallel execution for specific tests[ParallelLimit<T>] with custom limit classes to control concurrency[Repeat(n)] with [ParallelLimit<T>] for load testing scenarios[Fact] with [Test][Theory] with [Test] and use [Arguments] for data[InlineData] with [Arguments][MemberData] with [MethodData]Assert.Equal with await Assert.That(actual).IsEqualTo(expected)Why TUnit over xUnit?
TUnit offers a modern, fast, and flexible testing experience with advanced features not present in xUnit, such as asynchronous assertions, more refined lifecycle hooks, and improved data-driven testing capabilities. TUnit's fluent assertions provide clearer and more expressive test validation, making it especially suitable for complex .NET projects.
Weekly Installs
7.3K
Repository
GitHub Stars
27.0K
First Seen
Feb 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex7.3K
gemini-cli7.3K
opencode7.2K
cursor7.2K
github-copilot7.2K
kimi-cli7.2K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
AI智能体长期记忆系统 - 精英级架构,融合6种方法,永不丢失上下文
1,200 周安装
AI新闻播客制作技能:实时新闻转对话式播客脚本与音频生成
1,200 周安装
Word文档处理器:DOCX创建、编辑、分析与修订痕迹处理全指南 | 自动化办公解决方案
1,200 周安装
React Router 框架模式指南:全栈开发、文件路由、数据加载与渲染策略
1,200 周安装
Nano Banana AI 图像生成工具:使用 Gemini 3 Pro 生成与编辑高分辨率图像
1,200 周安装
SVG Logo Designer - AI 驱动的专业矢量标识设计工具,生成可缩放品牌标识
1,200 周安装
.And operator: await Assert.That(value).IsNotNull().And.IsEqualTo(expected).Or operator for alternative conditions: await Assert.That(value).IsEqualTo(1).Or.IsEqualTo(2).Within(tolerance) for DateTime and numeric comparisons with toleranceAssert.True with await Assert.That(condition).IsTrue()Assert.Throws<T> with await Assert.That(action).Throws<T>()[Before(Test)]/[After(Test)]IClassFixture<T> with [Before(Class)]/[After(Class)]