前提条件
- .NET 10 SDK
- Docker(集成测试需要 SQL Server + RabbitMQ)
命令
# 运行所有测试dotnet test
# 运行特定项目dotnet test tests/BitzOrcas.Unit.Testsdotnet test tests/BitzOrcas.Application.Testsdotnet test tests/BitzOrcas.Architecture.Tests
# 带过滤器运行dotnet test --filter "FullyQualifiedName~NoteService"
# 带详细输出运行dotnet test --verbosity detailed
# 带覆盖率运行dotnet test --collect:"XPlat Code Coverage"
# 运行特定框架dotnet test --framework net10.0测试项目
| 项目 | 需要的基础设施 | 典型耗时 |
|---|---|---|
| Unit.Tests | 无 | < 1s |
| Application.Tests | 无 | < 2s |
| Architecture.Tests | 无 | < 1s |
| Integration.Tests | Docker(SQL Server + RabbitMQ) | 5-30s |
| CodeGeneration.Tests | 无 | < 2s |
CI 配置
# GitHub Actions 示例- name: Run tests run: dotnet test --verbosity minimal --logger trx