Code coverage helps you detect which areas of your application are not covered with tests. Imagine if you have a number of classes in your domain and you have tests for them. In order to determine which method has tests written for it, you would have to manually check the tests to see if it has any tests that cover that method. Also, you would have to check if the test for that method covers all possibilities inside that method; This refers to if statements and branching.
As is turns out, a package I wrote called Ekko that helps you detect which menu item is active based on current URL and apply an appropriate CSS class to that item, already has tests written for it in PHPUnit. This is the perfect scenario for demonstrating what code coverage is, how to achieve maximum code coverage and why.
Laravel comes out-of-the-box with great testing suite built on PHPUnit. No API should be left untested.
We will create a new Laravel application which connects to the API that we have built in the previous lessons.