<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38" -->

---
title: Find Unexpected Test Inputs with Fuzz for Pest | daily.dev
description: Fuzz is a new package by Jon Purvis that brings coverage-guided fuzz testing to Pest 5, using nikic's PHP-Fuzzer under the hood to generate mutated string...
canonical: https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Find Unexpected Test Inputs with Fuzz for Pest | daily.dev
og:description: Fuzz is a new package by Jon Purvis that brings coverage-guided fuzz testing to Pest 5, using nikic's PHP-Fuzzer under the hood to generate mutated string...
og:url: https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38
og:image: https://api.daily.dev/og/posts/e3lhuxQ38.png
og:image:alt: Find Unexpected Test Inputs with Fuzz for Pest
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Find Unexpected Test Inputs with Fuzz for Pest

**[Laravel News](https://daily.dev/sources/ln)** · 4 min read · 1 upvotes · 3 comments

## Summary

Fuzz is a new package by Jon Purvis that brings coverage-guided fuzz testing to Pest 5, using nikic's PHP-Fuzzer under the hood to generate mutated string inputs and surface failures beyond hand-written test cases. It requires PHP 8.4+ and Pest 5, installed via Composer. The walkthrough builds a fuzz test for a rate-limit parser, showing how seed(), withDictionary(), runs(), and maxLen() configure the search, and demonstrates how keeping the target function outside test() is necessary for coverage tracking since Fuzz runs in a separate PHP process. The example fuzzer discovers an input causing a DivisionByZeroError, and the piece explains failure handling, allow() for exception filtering, per-input timeouts via pcntl, and when coverage-guided fuzzing is most valuable (parsers with successive validation steps) versus simple helpers.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://laravel-news.com/pest-fuzz>

## Questions this post answers

### How do I add coverage-guided fuzz testing to a Pest 5 test suite in PHP?

Install the Fuzz package by Jon Purvis via Composer with 'composer require jonpurvis/fuzz --dev', which requires PHP 8.4+ and Pest 5. Define a target function outside your test() call, then use fuzz($target)->seed([...])->withDictionary([...])->runs(2000)->maxLen(16)->run('name') inside a Pest test to generate and mutate inputs, surfacing failures like TypeError or unsuppressed warnings.

_Track fuzz testing tools like Fuzz for Pest as your PHP suite evolves, curated daily on daily.dev._

### Why does my Fuzz for Pest target function record no code coverage?

Coverage tracking fails when the target closure is passed directly with Closure::fromCallable() instead of being defined as a standalone function outside test(). Fuzz runs the target in a separate PHP process where Pest's generated test class is unavailable, so relying on that class breaks instrumentation. Defining the target function outside test() avoids this dependency and restores coverage-guided behavior, as observed in Fuzz v1.0.1.

_Developers debugging fuzz test coverage gaps can follow PHP testing fixes like this via daily.dev._

### What is coverage-guided fuzzing and how does it differ from random input testing?

Coverage-guided fuzzing tracks which code paths generated inputs reach, saving inputs that hit previously unexplored routes into a corpus to generate further variations, unlike plain random fuzzing which does not use feedback. PHP-Fuzzer implements this by tracking transitions between code blocks and their execution frequency, letting the fuzzer push past early validation checks like a bracket check to exercise deeper parsing logic.

_Understanding fuzzing strategy helps developers pick the right testing approach on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@leonidbugaev** · 0 upvotes

> Fuzz found 5/ because the missing window casts to 0. I'd pin that crash into a named dataset after the fix. A later green run only means it didn't find another crash in that budget.

**@agustinbarrientos** · 0 upvotes

> Have PHP-Fuzzer upgrades ever broken an old corpus for you? I'd probably pin the version in CI. Reproducing a crash is hard enough already.

**@michalfilo** · 0 upvotes

> I love fuzzing, but is the point is to go more gray box, not only blackbox so we can increase coverage and find more issues.

## Similar posts on daily.dev

- [How Mutation Testing Exposes the Truth \(PHP 2026 Edition\)](https://daily.dev/posts/how-mutation-testing-exposes-the-truth-php-2026-edition--qjofaye9n) · CodeCraft Diary · 0 upvotes · 0 comments
- [Fuzz Testing in Go](https://daily.dev/posts/fuzz-testing-in-go-sq6gh04sy) · Medium · 1 upvotes · 1 comments
- [Everything we have](https://daily.dev/posts/everything-we-have-ttxgg8qae) · PHPUnit Expert · 1 upvotes · 1 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Find Unexpected Test Inputs with Fuzz for Pest","url":"https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38"},"datePublished":"2026-09-08T14:02:21.579Z","dateModified":"2026-09-14T06:21:34.761Z","description":"Fuzz is a new package by Jon Purvis that brings coverage-guided fuzz testing to Pest 5, using nikic's PHP-Fuzzer under the hood to generate mutated string...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8d203648de928aff7e721fbee7a7d8f1?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8d203648de928aff7e721fbee7a7d8f1?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Laravel News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Laravel News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ln","url":"https://daily.dev/sources/ln"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"testing,php,laravel","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Laravel News","item":"https://daily.dev/sources/ln"},{"@type":"ListItem","position":3,"name":"Find Unexpected Test Inputs with Fuzz for Pest"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38","comment":[{"@type":"Comment","text":"Fuzz found 5/ because the missing window casts to 0. I’d pin that crash into a named dataset after the fix. A later green run only means it didn’t find another crash in that budget.","datePublished":"2026-09-08T15:07:00.583Z","url":"https://daily.dev/posts/e3lhuxQ38#c-ce9Nkq8TY","author":{"@type":"Person","name":"Leonid Bugaev","url":"https://daily.dev/leonidbugaev","image":"https://lh3.googleusercontent.com/a/ACg8ocLhMgurwTmJElWaH9A8Ju8cHvZxgMCDt009jEYkmFCyUGAoaGSw=s96-c"}},{"@type":"Comment","text":"Have PHP-Fuzzer upgrades ever broken an old corpus for you? I’d probably pin the version in CI. Reproducing a crash is hard enough already.","datePublished":"2026-09-09T09:17:41.928Z","url":"https://daily.dev/posts/e3lhuxQ38#c-RxgdTbUxt","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}},{"@type":"Comment","text":"I love fuzzing, but is the point is to go more gray box, not only blackbox so we can increase coverage and find more issues.","datePublished":"2026-09-13T18:48:10.918Z","url":"https://daily.dev/posts/e3lhuxQ38#c-7uzxx4K0B","author":{"@type":"Person","name":"Michal Filo","url":"https://daily.dev/michalfilo","image":"https://lh3.googleusercontent.com/a/ACg8ocJw7RT2L5Tl9Qa2OnmI7uwXbrBSH2qT6cLpHU8fAuHxrbOUHA=s96-c"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/find-unexpected-test-inputs-with-fuzz-for-pest-e3lhuxq38#faq","mainEntity":[{"@type":"Question","name":"How do I add coverage-guided fuzz testing to a Pest 5 test suite in PHP?","acceptedAnswer":{"@type":"Answer","text":"Install the Fuzz package by Jon Purvis via Composer with 'composer require jonpurvis/fuzz --dev', which requires PHP 8.4+ and Pest 5. Define a target function outside your test() call, then use fuzz($target)-\u003eseed([...])-\u003ewithDictionary([...])-\u003eruns(2000)-\u003emaxLen(16)-\u003erun('name') inside a Pest test to generate and mutate inputs, surfacing failures like TypeError or unsuppressed warnings. Track fuzz testing tools like Fuzz for Pest as your PHP suite evolves, curated daily on daily.dev."}},{"@type":"Question","name":"Why does my Fuzz for Pest target function record no code coverage?","acceptedAnswer":{"@type":"Answer","text":"Coverage tracking fails when the target closure is passed directly with Closure::fromCallable() instead of being defined as a standalone function outside test(). Fuzz runs the target in a separate PHP process where Pest's generated test class is unavailable, so relying on that class breaks instrumentation. Defining the target function outside test() avoids this dependency and restores coverage-guided behavior, as observed in Fuzz v1.0.1. Developers debugging fuzz test coverage gaps can follow PHP testing fixes like this via daily.dev."}},{"@type":"Question","name":"What is coverage-guided fuzzing and how does it differ from random input testing?","acceptedAnswer":{"@type":"Answer","text":"Coverage-guided fuzzing tracks which code paths generated inputs reach, saving inputs that hit previously unexplored routes into a corpus to generate further variations, unlike plain random fuzzing which does not use feedback. PHP-Fuzzer implements this by tracking transitions between code blocks and their execution frequency, letting the fuzzer push past early validation checks like a bracket check to exercise deeper parsing logic. Understanding fuzzing strategy helps developers pick the right testing approach on daily.dev."}}]}
```

