Linux command
dotnet-test 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Run tests
dotnet test
Run tests in specific project
dotnet test [tests/Tests.csproj]
Run with filter
dotnet test --filter "[FullyQualifiedName~UnitTests]"
Run specific test
dotnet test --filter "Name=[TestMethodName]"
Run with verbosity
dotnet test --verbosity [detailed]
Run without build
dotnet test --no-build
Generate coverage report
dotnet test --collect:"XPlat Code Coverage"
说明
dotnet test executes unit tests in .NET projects using the configured test framework adapter. It supports popular testing frameworks including MSTest, NUnit, and xUnit through their respective NuGet packages. The command discovers test methods through framework-specific attributes, executes them, and reports results including pass/fail status, execution time, and detailed failure information. It integrates with code coverage tools and CI/CD pipelines through various loggers and output formats.
参数
- --filter _expression_
- Filter tests by expression.
- --no-build
- Don't build before testing.
- --no-restore
- Don't restore before testing.
- -c, --configuration _CONFIG_
- Build configuration (e.g., Debug, Release).
- -v, --verbosity _level_
- Verbosity (quiet, minimal, normal, detailed, diagnostic).
- --logger _logger_
- Test logger.
- --collect _data_
- Enable data collector.
- --blame
- Run tests in blame mode.
- -r, --results-directory _dir_
- Results directory.
FAQ
What is the dotnet-test command used for?
dotnet test executes unit tests in .NET projects using the configured test framework adapter. It supports popular testing frameworks including MSTest, NUnit, and xUnit through their respective NuGet packages. The command discovers test methods through framework-specific attributes, executes them, and reports results including pass/fail status, execution time, and detailed failure information. It integrates with code coverage tools and CI/CD pipelines through various loggers and output formats.
How do I run a basic dotnet-test example?
Run `dotnet test` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --filter _expression_ do in dotnet-test?
Filter tests by expression.