Bootloader code is not covered: the app boots before the coverage interceptor
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Read src/Stage.php and src/Internal/Interceptor/BootInterceptor.php, then compare the boot interceptor order with Testo's InterceptorOptions::ORDER_COVERAGE. Reproduce with a package test case extending Spiral\Testing\TestCase and a bootloader in defineBootloaders(), collecting line coverage or Infection results. Done when bootloader init()/boot() lines are attributed to each test and their mutants are included in mutation testing.
Written by the indexing model from the issue text.
Description
Description
With spiral/testing 4.x the application boots outside Testo's coverage window, so code run in bootloader init()/boot() is not credited to any test. In spiral-packages/symfony-validator, migrating the Functional suite from a hand-rolled kernel (booted in the test body via #[BeforeTest]) to Spiral\Testing\TestCase dropped line coverage from 99/99 to 92/99: the missing lines are all in ValidatorBootloader. Infection is affected silently: it generated 50 mutants instead of 53 (the bootloader lines have no covering test, so their mutants are never produced) and still reported 100% MSI.
The cause is interceptor order. BootInterceptor runs at Stage::BOOT = 300_000 (src/Stage.php#L27, src/Internal/Interceptor/BootInterceptor.php#L18), while the coverage interceptor sits at InterceptorOptions::ORDER_COVERAGE = 1_001_000_000 (testo core/Pipeline/Attribute/InterceptorOptions.php#L51), i.e. inner to the boot. Everything the app does while booting happens before coverage collection starts.
Steps to reproduce
- A package test suite extending
Spiral\Testing\TestCase, with the package bootloader indefineBootloaders(). - Run Testo with coverage (or Infection via testo/bridge-infection).
- The bootloader's
init()/boot()lines are reported as uncovered, although every test boots them.
Workaround: call $this->initApp() inside the test body; the second boot runs inside the coverage window.
Proposed solution
Make the boot visible to coverage, e.g. by booting inside the coverage window (an order inner to ORDER_COVERAGE) or by attributing the boot to the test some other way. A boot that runs once per test should count as that test's coverage, otherwise mutation testing silently loses mutants instead of reporting them as uncovered.
- Dominant language
- PHP
- Stars
- 7
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spiral/testing
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Add support for parallel testingMay be free again @butschster claimed this 1112 days ago, and no pull request is open. Openenhancement
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 20/100
-
Remake auth testingMay be free again @butschster claimed this 1409 days ago, and no pull request is open. Openenhancement
Similar issues
-
area/import type/enhancement when/later
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
parime/glpi-iso27001-management#1165 ·
Maintainers usually reply within 1 day
-
15.0
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
opnsense/plugins#5976 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100