ln-743-test-infrastructure

L3 Worker - Sets up testing frameworks and coverage tools

Main Workflow

stateDiagram-v2 [*] --> CheckExisting: Start Test Setup state CheckExisting { [*] --> ScanTestFiles ScanTestFiles --> EvaluateSetup EvaluateSetup --> [*] } CheckExisting --> Decision: Tests Evaluated state Decision { [*] --> NoTests [*] --> PartialSetup [*] --> CompleteSetup NoTests --> Create: Create new PartialSetup --> AskUser: Extend or replace? CompleteSetup --> Skip: Inform user } Decision --> CreateConfig: Action Determined state CreateConfig { [*] --> DetectStack DetectStack --> Vitest: TypeScript DetectStack --> xUnit: .NET DetectStack --> Pytest: Python Vitest --> [*] xUnit --> [*] Pytest --> [*] } CreateConfig --> CreateStructure: Config Created CreateStructure --> CreateSampleTests: Directories Created CreateSampleTests --> Verify: Sample Tests Added Verify --> [*]: Tests Passing

Test Framework Selection

flowchart TD Start([Detect Stack]) --> Check{Project Type?} Check -->|TypeScript| TS[TypeScript/React] Check -->|.NET| NET[.NET] Check -->|Python| PY[Python] subgraph TS[TypeScript Stack] Vitest[Vitest] RTL[React Testing Library] V8[v8 Coverage] end subgraph NET[.NET Stack] xUnit[xUnit] Moq[Moq] Coverlet[Coverlet] FA[FluentAssertions] end subgraph PY[Python Stack] Pytest[pytest] PytestCov[pytest-cov] PytestAsync[pytest-asyncio] end TS --> Config([Config + Sample Tests]) NET --> Config PY --> Config classDef typescript fill:#3178C6,color:white classDef dotnet fill:#512BD4,color:white classDef python fill:#3776AB,color:white class Vitest,RTL,V8 typescript class xUnit,Moq,Coverlet,FA dotnet class Pytest,PytestCov,PytestAsync python

AAA Pattern (Arrange-Act-Assert)

flowchart LR subgraph Arrange["1. Arrange"] Setup[Setup test data] Mocks[Create mocks] Instance[Create instance] end subgraph Act["2. Act"] Execute[Execute code under test] Capture[Capture result] end subgraph Assert["3. Assert"] Verify[Verify result] CheckMocks[Verify mock calls] end Arrange --> Act --> Assert classDef arrange fill:#FFE4B5 classDef act fill:#E6E6FA classDef assert fill:#90EE90 class Setup,Mocks,Instance arrange class Execute,Capture act class Verify,CheckMocks assert

Coverage Thresholds

flowchart TD Tests([Run Tests]) --> Coverage{Check Coverage} Coverage -->|Lines ≥ 80%| LinesOK[Lines PASS] Coverage -->|Lines < 80%| LinesFail[Lines FAIL] LinesOK --> Branches{Branches?} Branches -->|≥ 80%| BranchesOK[Branches PASS] Branches -->|< 80%| BranchesFail[Branches FAIL] BranchesOK --> Functions{Functions?} Functions -->|≥ 80%| FunctionsOK[Functions PASS] Functions -->|< 80%| FunctionsFail[Functions FAIL] FunctionsOK --> Success([All Thresholds Met]) LinesFail --> Failure([CI FAILS]) BranchesFail --> Failure FunctionsFail --> Failure classDef pass fill:#90EE90 classDef fail fill:#FFB6C1 class LinesOK,BranchesOK,FunctionsOK,Success pass class LinesFail,BranchesFail,FunctionsFail,Failure fail

Test Directory Structure

flowchart TD subgraph TypeScript["TypeScript (Co-located)"] TSrc[src/] TComp[components/] TButton[Button.tsx] TButtonTest[Button.test.tsx] TSetup[test/setup.ts] TSrc --> TComp TComp --> TButton TComp --> TButtonTest TSrc --> TSetup end subgraph DotNet[".NET (Separate)"] NSrc[src/Project.Api/] NTests[tests/Project.Tests/] NControllers[Controllers/] NServices[Services/] NSrc -.-> NTests NTests --> NControllers NTests --> NServices end subgraph Python["Python (tests/ folder)"] PSrc[src/] PTests[tests/] PUnit[unit/] PInt[integration/] PConftest[conftest.py] PSrc -.-> PTests PTests --> PUnit PTests --> PInt PTests --> PConftest end