[Back to table of contents](./README.md)

# 11. Writing and running Tests

## When to use this flow

Use this after feature implementation is done and you need to verify that it really works as intended. Verification splits into two different branches: automated code tests and manual verification that requires human judgment.

## Overall flow

```
1. write test cases -> 2. run test sheet (code test + e2e test) -> 3. if results differ from expectations, fix and rerun
```

| Step | What happens |
|---|---|
| 1. write test cases | Use `ywc-gen-testcase` to create PR / Task / diff-based manual verification testsheets for developers and QA |
| 2a. code test | Run unit / integration tests using the project's existing test runner |
| 2b. e2e test | Run flows generated by `ywc-e2e-test-strategy` - see [12. E2E Test automation strategy](./10-e2e-test-strategy.md) |
| 3. rerun | Fix results that do not match expectations, then rerun only the relevant test |

## `ywc-gen-testcase` examples

**Create a dev+QA testsheet from a PR number**
```
ywc-gen-testcase 250
```

**Use the current diff, QA-only audience, Japanese output**
```
ywc-gen-testcase --from-diff --audience qa --lang ja
```

**Task-based, including regression items**
```
ywc-gen-testcase 000020-010 --include-regression
```

## Manual verification vs automation: when to use what

| Verification target | Method |
|---|---|
| Visual/pixel accuracy, exploratory UX judgment | `ywc-gen-testcase` (manual) - areas that require human judgment |
| One-time migration, 3rd-party OAuth flow, email/SMS verification | `ywc-gen-testcase` (manual) - usually too costly to automate for the value |
| Login/logout, core feature happy path, flows with repeated regressions | `ywc-e2e-test-strategy` (automated) - see [12](./10-e2e-test-strategy.md) |
| Function/module-level logic | The project's existing unit/integration test runner |

The two methods are not substitutes; they **complement** each other. For UX judgment that automation cannot catch, supplement every release with a manual QA checklist from `ywc-gen-testcase`.

---

[Previous: 10. Entering an existing Repo for the first time](./08-onboarding-existing-repo.md) · [Next: 12. E2E Test automation strategy](./10-e2e-test-strategy.md)
