Exclude or test Laravel Service Providers while testing with coverage

  code-coverage, laravel, phpunit

I was required to test a website and also add code coverage to 100%, I have never done that, I know how to test laravel with phpunit using TDD, in that case everything is working fine. Then I installed xdebug to allow code coverage
./vendor/bin/phpunit --coverage-html reports/

My reports are almost to 100%, but the reports shows that BroadcastServiceProvider.php is not tested, but I am not using anything with that provider, I don’t know if in the future I will use it. I tried this:

<?php

namespace AppProviders;

use IlluminateSupportFacadesBroadcast;
use IlluminateSupportServiceProvider;

class BroadcastServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //Broadcast::routes();

        //require base_path('routes/channels.php');
    }
}

But the report still shows that file is 0.0% cover with test, How can I exclude it for coverage?


Additional question: the reports directory should be uploaded to the repository? if doesn’t, how are they going to know if the code is 100% cover?

Source: Laravel

Leave a Reply