Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Data-driven testing with PHPUnit
Feb 27, 2018 @ 17:54:24

The Laravel News site has a tutorial posted that approaches a common development task - writing tests - from a data-driven approach rather than a strictly functional one.

Testing your code is an essential part of the development process, but sometimes it could also be expensive when you try to emulate many uses cases based on a set of different input data.

In many cases, you could end up with a massive directory of tests repeating the same block of code over and over for each possible user interaction.

They start with an example of a feature to test (Markdown parsing) and how traditional testing would have methods for each of the transformations. With a data-driven approach they turn the tests around and make use of data providers to set up the initial string, transformer to use and the correct result. Code is included showing an example of this kind of testing for the same Markdown parsing example and what a failure would look like in a dataset with multiple items.

tagged: tutorial provider phpunit testing data datadriven markdown

Link: https://laravel-news.com/data-driven-testing-phpunit


Trending Topics: