Gherkin Implementation Plan
1. Vision & Objectives
To transition WepNG from a "Legacy Monolith" to a "Verified System" by using Gherkin (Reqnroll) to document business requirements as executable tests.
Why Gherkin?
- Documentation as Code: Replaces stale Word docs/Wikis with tests that fail if they are wrong.
- Safety Net: "Characterization Tests" lock in current behavior before we refactor for .NET Core/Docker.
- Bridge: Allows Business (Product Owners) to read/validate logic without knowing C#.
2. Roadmap Phases
Phase 1: Documentation & Specification (Current)
Goal: Use Gherkin to capture business knowledge before writing code.
- Specs Directory: Create
docs/specsto centralize behavior definitions. - Workflow:
- Feature File: Describe behavior in plain English (Gherkin).
- Pseudo-code Mapping: Briefly describe which classes/methods trigger the behavior (e.g.,
FeeController.CreatecallsFeeService.Validate).
- Pilot: Document
FeeControllervalidation logic.
Phase 2: Foundation (Future)
Goal: Establish the testing infrastructure to execute Phase 1 specs.
- Technical Stack:
- Framework: Reqnroll.
- Runner: xUnit.
- Project:
WepNG.Tests.Specs(.NET Framework 4.8).
- Infrastructure:
- Add project to Solution.
- Bind Phase 1 Gherkin steps to C# code.
Phase 3: Expansion (Core Domains)
Goal: Cover critical hotspots identified in Hotspot Analysis.
- Priority 1:
Orders(Creation logic). - Priority 2:
WepAccess(Authorization rules). - Priority 3:
Invoicing(Net Cost calculation).
3. Workflow (Documentation First)
- Analyze: Read legacy code to understand the "Hidden Rules".
- Document: Write
*.featureindocs/specs/[Context]. - Map: Write a companion
*.mapping.mdwith Pseudo-code explaining how to test it (e.g., "MockIDbContext, callSave(), assertErrorList"). - Review: Validate requirements with Product Owner / Team.
4. Risks & Mitigations
| Risk | Mitigation |
|---|---|
| Database State | Use transaction rollback or dedicated cleanup steps. |
| Legacy Coupling | Start with Integration Tests (Phase A) before attempting Unit Tests. |
| Performance | Tag slow integration tests as @integration to run them separately if needed. |
| Desync | Docs might drift from code if not executable. Mitigation: Periodic review until Phase 2 is active. |
| Ambiguity | "Magic" steps in Gherkin. Mitigation: Strict mapping.md requirements (Pseudo-code). |