|
| 1 | +# Testing and Quality |
| 2 | + |
| 3 | +Testing in this project is designed to catch regressions early while keeping contributor workflow practical. |
| 4 | + |
| 5 | +## Test Structure |
| 6 | + |
| 7 | +Tests are organized under `src/test/java` and mirror production package boundaries: |
| 8 | + |
| 9 | +- API tests for public contracts and utility behavior |
| 10 | +- framework tests for lifecycle, config, command, and loader logic |
| 11 | +- feature tests for feature-specific logic and edge cases |
| 12 | + |
| 13 | +Shared helpers live under `src/test/java/nl/hauntedmc/serverfeatures/util`. |
| 14 | + |
| 15 | +## Local Commands |
| 16 | + |
| 17 | +Run tests: |
| 18 | + |
| 19 | +```bash |
| 20 | +mvn -q test |
| 21 | +``` |
| 22 | + |
| 23 | +Run the full quality gate: |
| 24 | + |
| 25 | +```bash |
| 26 | +mvn -B verify |
| 27 | +``` |
| 28 | + |
| 29 | +Run lint checks: |
| 30 | + |
| 31 | +```bash |
| 32 | +mvn -B -DskipTests checkstyle:check |
| 33 | +``` |
| 34 | + |
| 35 | +Generate a local coverage report: |
| 36 | + |
| 37 | +```bash |
| 38 | +mvn -q test jacoco:report |
| 39 | +``` |
| 40 | + |
| 41 | +## What to Test |
| 42 | + |
| 43 | +When you change behavior, add or update tests near that behavior: |
| 44 | + |
| 45 | +- feature changes: user-visible logic, edge cases, fallback behavior |
| 46 | +- framework changes: lifecycle and dependency-resolution contracts |
| 47 | +- API changes: conversion, fallback, error handling, and stability guarantees |
| 48 | + |
| 49 | +Focus on regression-prone logic paths (branching rules, validation, parsing, state transitions). |
| 50 | + |
| 51 | +## Test Quality Bar |
| 52 | + |
| 53 | +Use these rules during authoring and review: |
| 54 | + |
| 55 | +- prefer behavior assertions over "does not throw" smoke checks; |
| 56 | +- avoid tests that only mirror declaration state (pure enum/constant checks); |
| 57 | +- avoid pure getter/setter round-trip tests unless they protect a real invariant; |
| 58 | +- assert observable outcomes for both happy and failure paths. |
| 59 | + |
| 60 | +## Coverage Workflow |
| 61 | + |
| 62 | +Use this when doing a full feature/class/method scan: |
| 63 | + |
| 64 | +1. Run `mvn -q test jacoco:report`. |
| 65 | +2. Review `target/site/jacoco/index.html` and sort by missed lines/branches. |
| 66 | +3. Use `target/site/jacoco/jacoco.csv` to find high-risk classes with high missed lines and branches. |
| 67 | +4. Add tests for behavior-heavy methods first. |
| 68 | + |
| 69 | +Prioritize methods with both high line miss and high branch count. |
| 70 | + |
| 71 | +## CI |
| 72 | + |
| 73 | +CI runs: |
| 74 | + |
| 75 | +- Checkstyle (`ci-lint.yml`) |
| 76 | +- Tests and coverage (`ci-tests-and-coverage.yml`) |
| 77 | + |
| 78 | +Tag pushes (`v*`) trigger release packaging and publication (`release-package.yml`). |
0 commit comments