Skip to content

test: enforce the test layout and hold the line coverage - #8

Open
YvesCesar wants to merge 2 commits into
refactor/option-values-in-srcfrom
test/structure-and-coverage
Open

YvesCesar wants to merge 2 commits into
refactor/option-values-in-srcfrom
test/structure-and-coverage

Conversation

@YvesCesar

Copy link
Copy Markdown
Member

Stacked on #6.

Nothing kept the tests next to the code they cover, or the covered lines from going down.

Test layout

tests/Unit/StructureTest.php fails when a plugin file has no test named after it, or when a test no longer has its file:

It runs in the unit suite, without WordPress. tests/Support/PluginFiles.php lists the files. Checked: a new src/ file without a test, a unit test without its src/ file and a spec with no matching plugin file each fail; the spec from #7 passes.

Coverage

  • composer coverage runs both suites with Xdebug over the main file and src/, and writes tests/.coverage/clover.xml. Today it measures 100% (119 of 119 lines).
  • A Coverage job in phpunit.yml runs it on PHP 8.3 and hands the report to octocov. .octocov.yml fails the run when coverage is below 95% or below the last report of main, which octocov keeps as a workflow artifact.
  • k1LoW/octocov-action is pinned by SHA (v1.5.2) and its version input to octocov v0.80.1, so neither the action nor the binary changes between runs.

The README lists the layout rule and the coverage floor.

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Comment thread .github/workflows/phpunit.yml Outdated
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants