sun7pro / phpunit-training-coverage

MIT License
1 stars 5 forks source link

How to get PHPUnit coverage? #1

Open tuanpt-0634 opened 4 years ago

tuanpt-0634 commented 4 years ago

Coverage driver

Để generate coverage report bằng PHPUnit, cần có coverage driver: image

Có 3 drivers bao gồm (ưu tiên từ trên xuống dưới):

NOTE: chạy trong docker container đã cài sẵn các extension pcov, xdebug

Coverage format

Có nhiều loại format cho coverage:

Code Coverage Options:
  --coverage-clover <file>    Generate code coverage report in Clover XML format
  --coverage-crap4j <file>    Generate code coverage report in Crap4J XML format
  --coverage-html <dir>       Generate code coverage report in HTML format
  --coverage-php <file>       Export PHP_CodeCoverage object to file
  --coverage-text=<file>      Generate code coverage report in text format [default: standard output]
  --coverage-xml <dir>        Generate code coverage report in PHPUnit XML format

Nhưng thông dụng nhất là --coverage-text thường dùng trong CI hoặc xem nhanh kết quả và --coverage-html để xem chi tiết dưới dạng web dashboard và --coverage-clover dùng cho Sun*CI

Tasks

nganltb-1258 commented 4 years ago

Text Format

pcov

image

phpdbg

image

XDebug

image

html Format

image

taipt-0504 commented 4 years ago

PCOV

Coverage Text image Coverage Html image

PHPDBG

Coverage Text image Coverage Html image

XDEBUG

Coverage Text image Coverage Html image

huongvnq-1722 commented 4 years ago

image image

image image image

image

datpn-1648 commented 4 years ago

PCOV Coverage Text Screenshot from 2020-06-15 17-09-58 Coverage Html Screenshot from 2020-06-15 17-15-23 PHPDBG Coverage Text Screenshot from 2020-06-15 17-18-04 Coverage Html Screenshot from 2020-06-15 17-18-56 XDEBUG Coverage Text Screenshot from 2020-06-15 17-20-21 Coverage Html Screenshot from 2020-06-15 17-21-09