一键导入
dotnet-test
.NET test execution patterns and diagnostics. Use when running tests, analyzing test failures, or configuring test options.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
.NET test execution patterns and diagnostics. Use when running tests, analyzing test failures, or configuring test options.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Interactively elicit, capture, and maintain software/system requirements as a living, traceable repository. Use whenever the user wants to gather, write, refine, or organize requirements — including producing or updating an SRS (software/system requirements specification), writing ADRs / architecture decision records, building a requirements traceability graph (DAG), or keeping a decision ledger. Trigger proactively when the working folder already holds requirements artifacts (a `requirements/` folder of YAML, `decisions/` ADRs, an `srs.md`, or `ledger.md`), or when the user shares documents that are clearly specs, RFCs, or feature briefs and wants them structured. Also use for phrases like "let's spec this out", "interview me about what we're building", "capture these requirements", "write a decision record", or "turn these notes into a spec". Not for project management, code review, application code, dependency manifests like requirements.txt, or hardware "system requirements" (RAM/CPU).
Use this skill whenever the user wants to create a bash script that drives an autonomous coding loop — scripts that run Claude Code on a schedule (cron, GitHub Actions, systemd timer) or on-demand to make repository improvements, execute plans, triage issues, or otherwise do agentic work with minimal human intervention. Triggers include phrases like "scout script", "autonomous script", "agent harness", "script that runs on a schedule", "script that implements a plan", ".scripts/*.sh", or any request for a bash script whose body is "run Claude Code with a prompt and commit the results". Always use this skill before writing such a script — it encodes the interview flow, the adversarial-reviewer pattern, and the locking/ledger conventions.
Task structure and atomic commit patterns for granular, verifiable work units
Conflict identification and resolution patterns for requirements, decisions, and plans
Context window management techniques for maintaining efficiency and preventing context bloat
Exploration map management for tracking discussed areas and uncharted territory during DISCUSS phase
| name | dotnet-test |
| description | .NET test execution patterns and diagnostics. Use when running tests, analyzing test failures, or configuring test options. |
| allowed-tools | Read, Grep, Glob, Bash |
# Run all tests in solution
dotnet test
# Run tests in specific project
dotnet test tests/MyApp.Tests/MyApp.Tests.csproj
# Run without build (faster if already built)
dotnet test --no-build
# Run without restore
dotnet test --no-restore
# Filter by fully qualified name (contains)
dotnet test --filter "FullyQualifiedName~OrderService"
# Filter by test name (exact match)
dotnet test --filter "Name=CreateOrder_ValidInput_ReturnsOrder"
# Filter by display name
dotnet test --filter "DisplayName~Create Order"
# Filter by trait (xUnit)
dotnet test --filter "Category=Unit"
dotnet test --filter "Category!=Integration"
# Multiple trait filters
dotnet test --filter "Category=Unit&Priority=High"
dotnet test --filter "Category=Unit|Category=Integration"
# Filter by class name
dotnet test --filter "ClassName=OrderServiceTests"
# Filter by namespace
dotnet test --filter "FullyQualifiedName~MyApp.Tests.Services"
# Combine with operators
# & (and), | (or), ! (not), ~ (contains), = (equals)
# Unit tests except slow ones
dotnet test --filter "Category=Unit&Category!=Slow"
# All tests in namespace containing "Order"
dotnet test --filter "FullyQualifiedName~Order&Category!=Integration"
# Quiet (minimal output)
dotnet test --verbosity quiet
dotnet test -v q
# Normal (default)
dotnet test --verbosity normal
# Detailed (shows all test names)
dotnet test --verbosity detailed
dotnet test -v d
# Diagnostic (maximum output)
dotnet test --verbosity diagnostic
# Console logger with verbosity
dotnet test --logger "console;verbosity=detailed"
# TRX (Visual Studio Test Results)
dotnet test --logger trx
# JUnit format (for CI systems)
dotnet test --logger "junit;LogFileName=results.xml"
# HTML report
dotnet test --logger "html;LogFileName=results.html"
# Multiple loggers
dotnet test --logger trx --logger "console;verbosity=detailed"
# Specify results output directory
dotnet test --results-directory ./TestResults
# Basic coverage collection
dotnet test --collect:"XPlat Code Coverage"
# With Coverlet
dotnet test /p:CollectCoverage=true
# Coverlet with specific format
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
# Multiple formats
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=\"opencover,cobertura\"
# Fail if coverage below threshold
dotnet test /p:CollectCoverage=true /p:Threshold=80
# Per-type thresholds
dotnet test /p:CollectCoverage=true /p:ThresholdType=line /p:Threshold=80
# Install report generator
dotnet tool install -g dotnet-reportgenerator-globaltool
# Generate HTML report
reportgenerator -reports:coverage.cobertura.xml -targetdir:coveragereport
# Control parallelism
dotnet test --parallel
# Limit parallel workers
dotnet test -- RunConfiguration.MaxCpuCount=4
# Disable parallel execution
dotnet test -- RunConfiguration.DisableParallelization=true
# Set test timeout (milliseconds)
dotnet test -- RunConfiguration.TestSessionTimeout=60000
// Per-test timeout (xUnit)
[Fact(Timeout = 5000)]
public void SlowTest() { }
// Per-test timeout (NUnit)
[Test, Timeout(5000)]
public void SlowTest() { }
<!-- test.runsettings -->
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<MaxCpuCount>4</MaxCpuCount>
<ResultsDirectory>./TestResults</ResultsDirectory>
<TestSessionTimeout>600000</TestSessionTimeout>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Format>cobertura</Format>
<Exclude>[*]*.Migrations.*</Exclude>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
# Use runsettings file
dotnet test --settings test.runsettings
| Pattern | Cause | Fix |
|---|---|---|
| Assert.Equal failed | Expected != Actual | Check logic, verify test data |
| NullReferenceException | Null not handled | Add null checks, verify setup |
| TimeoutException | Test too slow | Optimize or increase timeout |
| ObjectDisposedException | Using disposed object | Fix lifetime management |
| InvalidOperationException | Invalid state | Check test setup/order |
# Run single failing test with detailed output
dotnet test --filter "FullyQualifiedName~FailingTest" -v d
# Enable blame mode to catch hangs
dotnet test --blame
# Blame with hang detection
dotnet test --blame-hang --blame-hang-timeout 60s
# Run tests on file changes
dotnet watch test
# Watch specific project
dotnet watch --project tests/MyApp.Tests test
# Watch with filter
dotnet watch test --filter "Category=Unit"
| Code | Meaning |
|---|---|
| 0 | All tests passed |
| 1 | Tests failed |
| 2 | Command line error |
# Azure DevOps
- task: DotNetCoreCLI@2
inputs:
command: test
arguments: '--configuration Release --logger trx'
# GitHub Actions
- run: dotnet test --configuration Release --logger "trx;LogFileName=test-results.trx"
See test-filtering.md for advanced filtering patterns.