Bootloader code is not covered: the app boots before the coverage interceptor

Aperta
#96 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
testing

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

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

  1. A package test suite extending Spiral\Testing\TestCase, with the package bootloader in defineBootloaders().
  2. Run Testo with coverage (or Infection via testo/bridge-infection).
  3. 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.

Lingua principale
PHP
Stelle
7
Fork
7
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di spiral/testing

Tutte le issue di spiral/testing

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.