From 2f1e983c9dc5cf4c4b58dca7a880705c2103fcf0 Mon Sep 17 00:00:00 2001 From: moilanik Date: Mon, 8 Jun 2026 09:34:28 +0300 Subject: [PATCH] =?UTF-8?q?kehitys=20sykli=20m=C3=A4=C3=A4ritelty,=20tdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/ai-context.md | 16 ++ docs/test-plan/tdd-guide.md | 295 ++++++++++++++++++++++++++++++++++++ 2 files changed, 311 insertions(+) create mode 100644 docs/test-plan/tdd-guide.md diff --git a/docs/ai-context.md b/docs/ai-context.md index 9a0969b..22aa56f 100644 --- a/docs/ai-context.md +++ b/docs/ai-context.md @@ -20,6 +20,13 @@ Gitea Actions reusable workflow -kirjasto mikropalveluiden build-, testaus-, rap | `scripts/` | Jaetut bash-skriptit | | `report-service/` | Raporttipalvelun koodi (retention, indeksigenerointi) | | `docs/` | Arkkitehtuuri-, vaatimus- ja konfiguraatiodokumentaatio | +| `docs/tickets/` | Toteutustiketit (0001–0012), yksi per feature-branch | +| `docs/test-plan/` | TDD-opas: 3-kerrosmalli, kehityslooppi, mock, kontekstikuratointi | +| `docs/test-plan/tdd-guide.md` | Testivetoisen kehityksen menetelmädokumentti | +| `tests/` | Bats-testit skripteille ja workflow-validointi | +| `tests/features/` | Cucumber `.feature`-tiedostot (yksi per tiketti, tägätty @mock/@real/@ticket-NNNN) | +| `tests/helpers/` | Jaettu mock-palvelin (Gitea API + MinIO) | +| `.gitea/workflows/ci.yml` | Kirjaston oma CI — dogfood (käyttää itse itseään) | ## Key Technical Decisions - **Vain Gitea.** Ei multi-platform-tukea (GitLab, BitBucket, GitHub) @@ -41,6 +48,15 @@ Gitea Actions reusable workflow -kirjasto mikropalveluiden build-, testaus-, rap - Workflow-triggerit: `push` branchiin tai `workflow_dispatch` - Skriptien kutsuminen tapahtuu workflow-stepeistä, ei paikallisesti - `ci-flow-values.yaml` validointi: skeema `docs/config-model.md`:ssa +- Bats-testit: `bats tests/` — ajaa kaikki skripti- ja workflow-testit +- Testit vaativat: `bats` (Bash Automated Testing System), `jq`, `yq` + +## Development Process +- TDD: Red-Green-Refactor jokaiselle tiketille. Testit ensin, toteutus vasta kun testi epäonnistuu. +- Ominaisuusbranchit: `feature/NNNN-tiketin-nimi` (esim. `feature/0001-report-status-sh`) +- Yksi tiketti per sessio. Tiketit riippuvuusjärjestyksessä 0001 → 0012. +- Ennen jokaista tikettiä: lataa `docs/test-plan/tdd-guide.md` + tiketin Required context -skillin lisäksi +- Dogfood: `.gitea/workflows/ci.yml` — kirjaston oma CI käyttää omia reusable workflow'itaan ## What NOT to Do - Älä lisää tukea muille Git-alustoille (GitLab, BitBucket, GitHub) diff --git a/docs/test-plan/tdd-guide.md b/docs/test-plan/tdd-guide.md new file mode 100644 index 0000000..be7e428 --- /dev/null +++ b/docs/test-plan/tdd-guide.md @@ -0,0 +1,295 @@ +# Test-Driven Development Guide — Gitea Actions CI -kirjasto + +**Updated:** 2026-06-08 + +Tämä dokumentti kuvaa testivetoisen kehityksen menetelmän, testiarkkitehtuurin ja kehitysloopin tässä projektissa. + +--- + +## Kolmikerroksinen testiarkkitehtuuri + +``` +┌──────────────────────────────────────────────────────────────────────┐ +│ LAYER 1: Cucumber acceptance / E2E │ +│ Cucumber + Gherkin | tests/features/-.feature │ +│ Yksi feature file per tiketti. Käyttäjän näkökulma. │ +│ Tägätty: @mock, @real, @ticket-NNNN │ +│ Tiketti on valmis kun @mock-skenaariot GREEN │ +├──────────────────────────────────────────────────────────────────────┤ +│ LAYER 2: Workflow-validointi │ +│ Bats | tests/workflows.bats │ +│ YAML-skeema, input/output -kontrakti │ +│ Käytetään kun tiketti koskee reusable workflow'ta │ +├──────────────────────────────────────────────────────────────────────┤ +│ LAYER 3: Bash-yksikkötestit │ +│ Bats | tests/