Test Trait Tagging
Analyze an existing test suite and apply a standardized set of trait tags to each test method, giving teams visibility into their test distribution (positive vs. negative, critical-path coverage, smoke tests, etc.).
When to Use
- Auditing a test project to understand the mix of test types
- Adding trait attributes to untagged tests
- Generating a summary report of trait distribution across a test suite
- Reviewing whether critical paths have sufficient coverage
When Not to Use
- Writing new tests from scratch (use
writing-mstest-tests)
- Running or filtering tests (use
run-tests)
- Migrating between test frameworks
Inputs
| Input |
Required |
Description |
| Test project or files |
Yes |
Path to the test project, folder, or specific test files to analyze |
| Scope |
No |
tag (apply attributes), audit (report only), or both (default: both) |
| Framework |
No |
Auto-detected. Override with mstest, xunit, or nunit if detection fails |
Trait Taxonomy
Use exactly these trait names and values. Do not invent new trait values outside this table.
| Trait Value |
Meaning |
Heuristics |
positive |
Verifies expected behavior under normal/valid conditions |
Asserts success, valid output, expected state, no exceptions for valid input |
negative |
Verifies correct handling of invalid input, errors, or edge cases |
Asserts exceptions, error codes, validation failures, rejects bad input |
boundary |
Tests limits, thresholds, empty/null inputs, min/max values |
Operates on 0, -1, int.MaxValue, empty string, null, empty collection, boundary of valid range |
critical-path |
Core workflow that must never break; breakage blocks users |
Tests the primary success scenario of a key public API or user-facing feature |
smoke |
Quick sanity check that the system is operational |
Fast, no complex setup, verifies basic wiring (e.g., service resolves, endpoint returns 200) |
regression |
Reproduces a specific previously-reported bug |
References a bug ID, issue number, or describes a fix in its name or comments |
integration |
Crosses process, network, or persistence boundaries |
Uses real database, HTTP client, file system, external service, or multi-component setup |
end-to-end |
Full user workflow spanning the entire application stack |
Exercises a complete scenario from entry point to final result, distinct from single-boundary integration |
performance |
Validates timing, throughput, or resource consumption |
Asserts on elapsed time, memory, allocations, or uses benchmark harness |
security |
Verifies authentication, authorization, input sanitization, or secrets handling |
Tests for SQL injection, XSS, CSRF, unauthorized access, token validation, permission checks |
concurrency |
Validates thread safety, parallelism, or async correctness |
Uses Task.WhenAll, locks, Parallel.ForEach, SemaphoreSlim, reproduces race conditions |
resilience |
Tests retry logic, timeouts, circuit breakers, or graceful degradation |
Asserts behavior under transient failures, network drops, or service unavailability (e.g., Polly policies) |
destructive |
Mutates shared or external state that is hard to roll back |
Deletes records, drops resources, modifies global config -- useful for CI isolation decisions |
configuration |
Verifies settings loading, defaults, environment behavior |
Tests missing config keys, invalid values, environment variable fallbacks, options validation |
flaky |
Known to intermittently fail (meta-tag for test health tracking) |
Mark tests the team knows are unreliable; used to quarantine or prioritize stabilization |
A single test may have multiple traits (e.g., both negative and boundary). At minimum, every test should receive one of positive or negative.
Workflow
Step 1: Detect the test framework
Examine project files and source code to determine the framework — see the dotnet-test-frameworks skill for the complete detection table (package references, test markers, assertion APIs, and skip annotations).
Step 2: Scan existing traits
Check which tests already have trait attributes:
| Framework |
Existing Attribute |
Example |
| MSTest |
[TestCategory("...")] |
[TestCategory("positive")] |
| xUnit |
[Trait("Category", "...")] |
[Trait("Category", "positive")] |
| NUnit |
[Category("...")] |
[Category("positive")] |
Record which tests already have tags to avoid duplication.
Step 3: Classify each test method
For each test method without traits, analyze:
- Method name -- names containing
Invalid, Fail, Error, Throw, Reject, BadInput, Null, Negative suggest negative
- Assertion type --
Assert.ThrowsException, Assert.Throws, Should().Throw() suggest negative
- Input values --
null, "", 0, -1, int.MaxValue, int.MinValue, empty collections suggest boundary
- Setup complexity -- minimal setup with basic assertions suggests
smoke; external dependencies suggest integration
- Comments and names -- references to issue numbers or "regression" / "bug" / "fix for #..." suggest
regression
- Timing assertions --
Stopwatch, BenchmarkDotNet, elapsed-time checks suggest performance
- Feature centrality -- tests on primary public API entry points or critical user workflows suggest
critical-path
- Security patterns -- validates auth, checks permissions, sanitizes input, tests for injection, handles tokens/secrets suggest
security
- Parallel/async constructs --
Task.WhenAll, Parallel.ForEach, locks, SemaphoreSlim, ConcurrentDictionary, race condition names suggest concurrency
- Fault injection -- simulates failures, tests retries, timeouts, or circuit breakers suggest
resilience
- State mutation -- deletes external records, drops resources, modifies shared/global state suggest
destructive
- Full-stack flow -- test spans entry point through data layer to final response, covering a complete user scenario suggest
end-to-end
- Config/settings -- loads configuration, tests missing keys, validates options, checks environment variables suggest
configuration
- Known instability -- test has
[Ignore]/[Skip] comments about flakiness, or names contain "flaky"/"intermittent" suggest flaky
- Default -- if the test verifies a normal success path, tag
positive
When in doubt between positive and negative, read the assertion: if it asserts success -> positive; if it asserts failure -> negative.
Step 4: Apply trait attributes
Add the appropriate attribute to each test method. Place trait attributes on the line directly above or below the existing test attribute.
MSTest:
[TestMethod]
[TestCategory("negative")]
[TestCategory("boundary")]
public void Parse_NullInput_ThrowsArgumentNullException() { ... }
xUnit:
[Fact]
[Trait("Category", "positive")]
[Trait("Category", "critical-path")]
public void CreateOrder_ValidItems_ReturnsConfirmation() { ... }
NUnit:
[Test]
[Category("regression")]
[Category("negative")]
public void Calculate_OverflowInput_ReturnsError() // Fix for #1234
{ ... }
Step 5: Generate trait summary
After tagging, produce a summary table:
## Trait Distribution
| Trait | Count | % of Total |
|---------------|-------|------------|
| positive | 42 | 53.8% |
| negative | 22 | 28.2% |
| boundary | 8 | 10.3% |
| critical-path | 12 | 15.4% |
| smoke | 3 | 3.8% |
| regression | 5 | 6.4% |
| integration | 4 | 5.1% |
| end-to-end | 2 | 2.6% |
| performance | 1 | 1.3% |
| security | 3 | 3.8% |
| concurrency | 2 | 2.6% |
| resilience | 1 | 1.3% |
| destructive | 1 | 1.3% |
| configuration | 2 | 2.6% |
| flaky | 1 | 1.3% |
| **Total tests** | **78** | -- |
Note: Percentages exceed 100% because tests can have multiple traits.
Include observations such as:
- Ratio of positive to negative tests
- Whether critical-path tests exist for key public APIs
- Any tests that could not be confidently classified (list them for manual review)
Validation
Common Pitfalls
| Pitfall |
Solution |
| Guessing traits without reading the test body |
Always read assertions and setup to classify accurately |
Tagging a test only as boundary without positive/negative |
Every test should also be positive or negative -- boundary is additive |
Using TestCategory syntax in an xUnit project |
Match the attribute style to the detected framework |
| Duplicating an existing category attribute |
Check for pre-existing traits in Step 2 before adding |
Over-tagging as critical-path |
Reserve for tests on primary public entry points, not every helper |
1---2name: test-tagging3description: Analyzes test suites and tags each test with a standardized set of traits (e.g., positive, negative, critical-path, boundary, smoke, regression). Use when the user wants to categorize, audit, or label tests with traits. Do not use for writing new tests, running tests, or migrating test frameworks.4license: MIT5---67# Test Trait Tagging89Analyze an existing test suite and apply a standardized set of trait tags to each test method, giving teams visibility into their test distribution (positive vs. negative, critical-path coverage, smoke tests, etc.).1011## When to Use1213- Auditing a test project to understand the mix of test types14- Adding trait attributes to untagged tests15- Generating a summary report of trait distribution across a test suite16- Reviewing whether critical paths have sufficient coverage1718## When Not to Use1920- Writing new tests from scratch (use `writing-mstest-tests`)21- Running or filtering tests (use `run-tests`)22- Migrating between test frameworks2324## Inputs2526| Input | Required | Description |27|-------|----------|-------------|28| Test project or files | Yes | Path to the test project, folder, or specific test files to analyze |29| Scope | No | `tag` (apply attributes), `audit` (report only), or `both` (default: `both`) |30| Framework | No | Auto-detected. Override with `mstest`, `xunit`, or `nunit` if detection fails |3132## Trait Taxonomy3334Use exactly these trait names and values. Do not invent new trait values outside this table.3536| Trait Value | Meaning | Heuristics |37|-------------|---------|------------|38| `positive` | Verifies expected behavior under normal/valid conditions | Asserts success, valid output, expected state, no exceptions for valid input |39| `negative` | Verifies correct handling of invalid input, errors, or edge cases | Asserts exceptions, error codes, validation failures, rejects bad input |40| `boundary` | Tests limits, thresholds, empty/null inputs, min/max values | Operates on `0`, `-1`, `int.MaxValue`, empty string, null, empty collection, boundary of valid range |41| `critical-path` | Core workflow that must never break; breakage blocks users | Tests the primary success scenario of a key public API or user-facing feature |42| `smoke` | Quick sanity check that the system is operational | Fast, no complex setup, verifies basic wiring (e.g., service resolves, endpoint returns 200) |43| `regression` | Reproduces a specific previously-reported bug | References a bug ID, issue number, or describes a fix in its name or comments |44| `integration` | Crosses process, network, or persistence boundaries | Uses real database, HTTP client, file system, external service, or multi-component setup |45| `end-to-end` | Full user workflow spanning the entire application stack | Exercises a complete scenario from entry point to final result, distinct from single-boundary `integration` |46| `performance` | Validates timing, throughput, or resource consumption | Asserts on elapsed time, memory, allocations, or uses benchmark harness |47| `security` | Verifies authentication, authorization, input sanitization, or secrets handling | Tests for SQL injection, XSS, CSRF, unauthorized access, token validation, permission checks |48| `concurrency` | Validates thread safety, parallelism, or async correctness | Uses `Task.WhenAll`, locks, `Parallel.ForEach`, `SemaphoreSlim`, reproduces race conditions |49| `resilience` | Tests retry logic, timeouts, circuit breakers, or graceful degradation | Asserts behavior under transient failures, network drops, or service unavailability (e.g., Polly policies) |50| `destructive` | Mutates shared or external state that is hard to roll back | Deletes records, drops resources, modifies global config -- useful for CI isolation decisions |51| `configuration` | Verifies settings loading, defaults, environment behavior | Tests missing config keys, invalid values, environment variable fallbacks, options validation |52| `flaky` | Known to intermittently fail (meta-tag for test health tracking) | Mark tests the team knows are unreliable; used to quarantine or prioritize stabilization |5354A single test may have **multiple traits** (e.g., both `negative` and `boundary`). At minimum, every test should receive one of `positive` or `negative`.5556## Workflow5758### Step 1: Detect the test framework5960Examine project files and source code to determine the framework — see the `dotnet-test-frameworks` skill for the complete detection table (package references, test markers, assertion APIs, and skip annotations).6162### Step 2: Scan existing traits6364Check which tests already have trait attributes:6566| Framework | Existing Attribute | Example |67|-----------|--------------------|---------|68| MSTest | `[TestCategory("...")]` | `[TestCategory("positive")]` |69| xUnit | `[Trait("Category", "...")]` | `[Trait("Category", "positive")]` |70| NUnit | `[Category("...")]` | `[Category("positive")]` |7172Record which tests already have tags to avoid duplication.7374### Step 3: Classify each test method7576For each test method without traits, analyze:77781. **Method name** -- names containing `Invalid`, `Fail`, `Error`, `Throw`, `Reject`, `BadInput`, `Null`, `Negative` suggest `negative`792. **Assertion type** -- `Assert.ThrowsException`, `Assert.Throws`, `Should().Throw()` suggest `negative`803. **Input values** -- `null`, `""`, `0`, `-1`, `int.MaxValue`, `int.MinValue`, empty collections suggest `boundary`814. **Setup complexity** -- minimal setup with basic assertions suggests `smoke`; external dependencies suggest `integration`825. **Comments and names** -- references to issue numbers or "regression" / "bug" / "fix for #..." suggest `regression`836. **Timing assertions** -- `Stopwatch`, `BenchmarkDotNet`, elapsed-time checks suggest `performance`847. **Feature centrality** -- tests on primary public API entry points or critical user workflows suggest `critical-path`858. **Security patterns** -- validates auth, checks permissions, sanitizes input, tests for injection, handles tokens/secrets suggest `security`869. **Parallel/async constructs** -- `Task.WhenAll`, `Parallel.ForEach`, locks, `SemaphoreSlim`, `ConcurrentDictionary`, race condition names suggest `concurrency`8710. **Fault injection** -- simulates failures, tests retries, timeouts, or circuit breakers suggest `resilience`8811. **State mutation** -- deletes external records, drops resources, modifies shared/global state suggest `destructive`8912. **Full-stack flow** -- test spans entry point through data layer to final response, covering a complete user scenario suggest `end-to-end`9013. **Config/settings** -- loads configuration, tests missing keys, validates options, checks environment variables suggest `configuration`9114. **Known instability** -- test has `[Ignore]`/`[Skip]` comments about flakiness, or names contain "flaky"/"intermittent" suggest `flaky`9215. **Default** -- if the test verifies a normal success path, tag `positive`9394When in doubt between `positive` and `negative`, read the assertion: if it asserts success -> `positive`; if it asserts failure -> `negative`.9596### Step 4: Apply trait attributes9798Add the appropriate attribute to each test method. Place trait attributes on the line directly above or below the existing test attribute.99100**MSTest:**101```csharp102[TestMethod]103[TestCategory("negative")]104[TestCategory("boundary")]105public void Parse_NullInput_ThrowsArgumentNullException() { ... }106```107108**xUnit:**109```csharp110[Fact]111[Trait("Category", "positive")]112[Trait("Category", "critical-path")]113public void CreateOrder_ValidItems_ReturnsConfirmation() { ... }114```115116**NUnit:**117```csharp118[Test]119[Category("regression")]120[Category("negative")]121public void Calculate_OverflowInput_ReturnsError() // Fix for #1234122{ ... }123```124125### Step 5: Generate trait summary126127After tagging, produce a summary table:128129```130## Trait Distribution131132| Trait | Count | % of Total |133|---------------|-------|------------|134| positive | 42 | 53.8% |135| negative | 22 | 28.2% |136| boundary | 8 | 10.3% |137| critical-path | 12 | 15.4% |138| smoke | 3 | 3.8% |139| regression | 5 | 6.4% |140| integration | 4 | 5.1% |141| end-to-end | 2 | 2.6% |142| performance | 1 | 1.3% |143| security | 3 | 3.8% |144| concurrency | 2 | 2.6% |145| resilience | 1 | 1.3% |146| destructive | 1 | 1.3% |147| configuration | 2 | 2.6% |148| flaky | 1 | 1.3% |149| **Total tests** | **78** | -- |150151Note: Percentages exceed 100% because tests can have multiple traits.152```153154Include observations such as:155- Ratio of positive to negative tests156- Whether critical-path tests exist for key public APIs157- Any tests that could not be confidently classified (list them for manual review)158159## Validation160161- [ ] Every test method has at least one trait attribute (`positive` or `negative` at minimum)162- [ ] No invented trait values outside the taxonomy table163- [ ] Existing trait attributes were preserved, not duplicated164- [ ] The trait summary table was generated165- [ ] The project still builds after changes (`dotnet build`)166167## Common Pitfalls168169| Pitfall | Solution |170|---------|----------|171| Guessing traits without reading the test body | Always read assertions and setup to classify accurately |172| Tagging a test only as `boundary` without `positive`/`negative` | Every test should also be `positive` or `negative` -- `boundary` is additive |173| Using `TestCategory` syntax in an xUnit project | Match the attribute style to the detected framework |174| Duplicating an existing category attribute | Check for pre-existing traits in Step 2 before adding |175| Over-tagging as `critical-path` | Reserve for tests on primary public entry points, not every helper |