SuperAPI AI 工具集

dotnet-add-testing

测试与质量

查看项目

更新于 10-16 01:13

技能介绍

用途:为已有的 .NET 项目补齐测试基础设施,只做测试项目脚手架,不涵盖深入测试策略。

主要能力:用 dotnet new xunit 创建测试项目并按 src/ 结构镜像到 tests/(.UnitTests、.IntegrationTests、*.FunctionalTests);配置 coverlet 覆盖率收集与阈值;建立测试专用 Directory.Build.props、CPM 包版本和 .editorconfig 放宽项。

基本用法:先运行 dotnet-version-detection 确定 SDK 与 TFM,再运行 dotnet-project-analysis 了解解决方案。然后创建并加入解决方案:dotnet new xunit -n MyApp.Core.UnitTests -o tests/MyApp.Core.UnitTests;dotnet sln add;dotnet add ... reference ...。覆盖率相关命令:dotnet test --collect:"XPlat Code Coverage";阈值用 /p:CollectCoverage=true /p:Threshold=80 /p:ThresholdType=line。报告:dotnet tool install -g dotnet-reportgenerator-globaltool 后运行 reportgenerator。验证:dotnet restore、dotnet build --no-restore、dotnet test --no-build。

适用场景:需要为 .NET 解决方案快速建立单元测试与集成测试骨架、统一覆盖率与 CI 阈值的团队。

限制:仅提供脚手架,集成测试模式、xUnit v3 特性、UI 与快照测试需参考相关技能;具体包版本与是否收费等资料未提供。