PHP Classes

Laravel Route Coverage: Report the coverage of Laravel project tests

Recommend this page to a friend!
  Info   View files Documentation   View files View files (39)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-08-11 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 13 This week: 2All time: 11,081 This week: 48Up
Version License PHP version Categories
laravel-route-covera 1.0MIT/X Consortium ...7HTML, Libraries, Console, Design Patt..., T..., P...
Description 

Author

Andey Iatsenko


Contributor

This package can report the coverage of Laravel project tests.

It can scan the current project tests to check which routes those tests cover.

The package can generate reports in the current terminal console or as HTML to show the number of project routes, the number of routes covered by tests, the percentage of the total number of routes covered, and listings of routes, controllers, methods, and actions.

Innovation Award
PHP Programming Innovation award nominee
August 2023
Nominee
Vote
One way to measure the quality of a software project is to measure the ability of the project code to test itself and verify that the code works as intended.

The projects with the best quality often provide tests that cover a significant part of the code.

This package provides means to measure the extension of the tests provided by a Laravel package to test its features implemented by routes.

This way, developers can understand how much of their project code is covered by tests. Therefore they can also have an idea of how many tests need to be added to improve the coverage of the project tests.

Manuel Lemos
Picture of Andrey Iatsenko
  Performance   Level  
Name: Andrey Iatsenko <contact>
Classes: 2 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 2x

Details

LaravelRouteCoverage

Packagist Version GitHub Workflow Status Coverage License Packagist Downloads Packagist Downloads

Laravel route coverage report.

With this package you can see the percentage of test coverage of your routes. Unless of course you do it through Laravel or PHPUnit tests.

How it works?

The package will scan all your tests collecting all the http queries that are called in them. After that, it will compare the results with the routes of your application. Routes are taken only by the App prefix to exclude vendor routes.

:scroll: Installation

The package can be installed via composer:

composer require yzen.dev/laravel-route-coverage --dev

:scroll: Usage

Generate report:

php artisan route:coverage

After executing the command, the result of the report will be displayed in the console in the following form:

<img width="1148" alt="console-all-routes" src="https://user-images.githubusercontent.com/24630195/157137803-d73fe73e-a0fc-49a1-8eb3-aeb3daf43b30.png">

Possible options:

php artisan route:coverage --group-by-controller

In this case, all the results will be grouped by controllers, displaying how many actions there are in the controller, and how many of them are covered by tests.

<img width="448" alt="console-group-by-controller" src="https://user-images.githubusercontent.com/24630195/157138734-03639864-ea6c-45eb-8819-6dc732da9e3c.png">

php artisan route:coverage --html

Due to the --html option, you will also receive a generated report in the html page. The report will be located in the public directory public/route-coverage

<img width="1721" alt="html-report" src="https://user-images.githubusercontent.com/24630195/157138963-a6a0d24c-2020-4546-845a-130897cc9545.png">

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagepublic (1 file)
Files folder imagesrc (4 files, 4 directories)
Files folder imagetests (5 files, 2 directories)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file coverage.xml Data Auxiliary data
Accessible without login Plain text file phpcs.xml Data Auxiliary data
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (2 files)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file code-analyze.yml Data Auxiliary data
  Accessible without login Plain text file tests.yml Data Auxiliary data

  Files folder image Files  /  public  
File Role Description
  Accessible without login Plain text file phpcs-junit.xml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageCommands (1 file)
Files folder imageconfig (1 file)
Files folder imageParser (1 file)
Files folder imageReport (1 file, 2 directories)
  Plain text file RouteCollection.php Class Class source
  Plain text file RouteCoverage.php Class Class source
  Plain text file RouterService.php Class Class source
  Plain text file ServiceProvider.php Class Class source

  Files folder image Files  /  src  /  Commands  
File Role Description
  Plain text file GenerateReportCommand.php Class Class source

  Files folder image Files  /  src  /  config  
File Role Description
  Accessible without login Plain text file route-coverage.php Aux. Auxiliary script

  Files folder image Files  /  src  /  Parser  
File Role Description
  Plain text file ParserFiles.php Class Class source

  Files folder image Files  /  src  /  Report  
File Role Description
Files folder imageHtml (1 file, 1 directory)
Files folder imageJunit (1 file)
  Plain text file AbstractReport.php Class Class source

  Files folder image Files  /  src  /  Report  /  Html  
File Role Description
Files folder imagetemplate (2 directories)
  Plain text file Reporter.php Class Class source

  Files folder image Files  /  src  /  Report  /  Html  /  template  
File Role Description
Files folder imagecss (1 file)
Files folder imagejs (1 file)

  Files folder image Files  /  src  /  Report  /  Html  /  template  /  css  
File Role Description
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data

  Files folder image Files  /  src  /  Report  /  Html  /  template  /  js  
File Role Description
  Accessible without login Plain text file bootstrap.bundle.min.js Data Auxiliary data

  Files folder image Files  /  src  /  Report  /  Junit  
File Role Description
  Plain text file Reporter.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageFakeTest (7 files)
Files folder imageSupport (4 files)
  Plain text file ParserDirectoryTest.php Class Class source
  Plain text file ReportHtmlTest.php Class Class source
  Plain text file ReportJunitTest.php Class Class source
  Plain text file RouterCoverageTest.php Class Class source
  Plain text file RouterServiceTest.php Class Class source

  Files folder image Files  /  tests  /  FakeTest  
File Role Description
  Plain text file DeleteRequest.php Class Class source
  Plain text file FakeMakesHttpRequests.php Class Class source
  Plain text file GetRequest.php Class Class source
  Plain text file JsonRequest.php Class Class source
  Plain text file PatchRequest.php Class Class source
  Plain text file PostRequest.php Class Class source
  Plain text file PutRequest.php Class Class source

  Files folder image Files  /  tests  /  Support  
File Role Description
  Plain text file ConfigTrait.php Class Class source
  Plain text file FakeDispatcher.php Class Class source
  Plain text file RouterArray.php Class Class source
  Plain text file RouterTrait.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:13
This week:2
All time:11,081
This week:48Up