Pest - PHP testing framework that goes above and beyond PHPUnit

Click for: original source

When building third-party APIs, it’s important to test your code in every runtime scenario you’ve seen or can foresee. For this, a robust and easy to use & maintain testing framework is a must. By Peter Villani.

Given the number of tests we perform, and trying to cover every function in our codebase, we needed to simplify the testing code and make it easier to maintain, understand, and debug. We also wanted to make sure our testing framework would require little effort to integrate into Laravel.

As PHP developers, we relied heavily on PHPUnit, but we switched over to the Pest Testing Framework, which simplified and reduced our large library of testing code. In this article, we take a look at Pest, a robust testing framework built on top of PHP’s standard testing library PHPUnit.

it('is an example, function () {
    assertTrue(true);
});

Pest removes the namespace and library references needed in PHPUnit, and it doesn’t require extending hundreds of functions. It simply needs you to specify the test function - making it far easier to maintain and debug. And also Pest gave us more information per test and for errors, Pest gives you direct access to the line of code that has failed. Good read!

[Read More]

Tags php web-development app-development tdd