---
name: step-02-unit-tests
description: Run unit tests to verify business logic
prev_step: steps/step-01-compile.md
next_step: steps/step-03-integration-tests.md
---

# Step 2: Unit Tests

## BLOCKING - All unit tests must pass

### 1. Locate the test project

```bash
# Find test project
ls tests/*/*.csproj 2>/dev/null || ls *Tests*/*.csproj 2>/dev/null
```

### 2. Run unit tests only

```bash
dotnet test {TestProject} --no-build --filter "FullyQualifiedName~Unit" --verbosity normal
```

If the filter doesn't match, try:

```bash
dotnet test {TestProject} --no-build --filter "Category!=Integration" --verbosity normal
```

### 3. Evaluate result

- **All tests passed** -> Proceed to step 3
- **Tests failed** -> Read the failure output:
  - Assertion failure -> Check if the test expectation matches the implementation
  - Exception thrown -> Check if the service/entity code is correct
  - Compilation error -> Should not happen (step 1 passed), but fix if it does
  - **Fix and re-run until all pass**

### 4. Store state

```
{unit_test_count} = number of tests that passed
{unit_test_result} = PASS or FAIL
```
