phpunit

  • A data provider runs before setUp

    Providers are collected during test discovery, long before any setUp has run, so a provider touching the application container or the database fails. String keys on the provider…

  • Transactions per test, and the three things that break

    Wrapping each test in a transaction and rolling back is much faster than migrating between tests, and three things do not survive it. The second connection case is…

  • Covered code MSI is the number that means something

    Three mutation metrics are reported and two of them mostly restate line coverage. Setting a threshold on covered MSI and none on the others is what stops the…

  • Laravel 8 moved the models and rewrote the factories

    A directory move, a factory rewrite and a route resolution change that breaks silently. Which of the three actually needs doing, and in what order.

  • A test that asserts on peak memory

    An N+1 fixed by eager loading can be replaced by a memory problem, and a query-count assertion reports the page as healthy while it hydrates forty thousand objects.…

  • A data provider with string keys reads better on failure

    A provider returning a plain list produces failures reported as “with data set #3”, and you count rows to find out which one. The provider runs before setUp,…

  • Mutation testing, and the tests that assert nothing

    94% coverage, and a suite that passes with the logic inverted. Coverage measures execution rather than verification, and there is a tool that measures the difference.

  • assertContains split, and why a blind rename is wrong

    The old function accepted an array or a string and the two behaviours have been separated, so a search and replace is wrong in one direction or the…

  • PHPUnit 9 removed what 8 deprecated, on schedule

    February brought the removals that 8 had warned about for a year, and a suite that ignored the warnings does not run at all. Rector handles the mechanical…

  • A flaky test quarantine, and the ticket that goes with it

    A test that fails one run in twenty trains the team to re-run the pipeline, and once that habit exists a real failure is re-run too. Quarantining without…