Skip to content
bitzorcas
EN

Guide

运行测试

如何运行测试 — CLI 命令、运行特定项目、测试过滤器和 CI 配置。

Last updated

前提条件

  • .NET 10 SDK
  • Docker(集成测试需要 SQL Server + RabbitMQ)

命令

Terminal window
# 运行所有测试
dotnet test
# 运行特定项目
dotnet test tests/BitzOrcas.Unit.Tests
dotnet test tests/BitzOrcas.Application.Tests
dotnet 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.TestsDocker(SQL Server + RabbitMQ)5-30s
CodeGeneration.Tests< 2s

CI 配置

# GitHub Actions 示例
- name: Run tests
run: dotnet test --verbosity minimal --logger trx