Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get PHPUnit coverage? #1

Open
3 tasks
tuanpt-0634 opened this issue Jun 12, 2020 · 4 comments
Open
3 tasks

How to get PHPUnit coverage? #1

tuanpt-0634 opened this issue Jun 12, 2020 · 4 comments

Comments

@tuanpt-0634
Copy link
Member

tuanpt-0634 commented Jun 12, 2020

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):

  • pcov cho PHPUnit version >= 8
    php -dextension=pcov.so -dpcov.enabled=1 -dpcov.directory=src ./vendor/bin/phpunit --coverage-text

    NOTE: pcov.directory=src, trong đó src là thư mục chứa source code

  • phpdbg
    phpdbg -qrr ./vendor/bin/phpunit --coverage-text
  • XDebug
    XDEBUG_MODE=coverage php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text

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
Copy link

nganltb-1258 commented Jun 15, 2020

Text Format

pcov

image

phpdbg

image

XDebug

image

html Format

image

@taipt-0504
Copy link

taipt-0504 commented Jun 15, 2020

PCOV

Coverage Text
image
Coverage Html
image

PHPDBG

Coverage Text
image
Coverage Html
image

XDEBUG

Coverage Text
image
Coverage Html
image

@huongvnq-1722
Copy link

huongvnq-1722 commented Jun 15, 2020

image
image

image
image
image

image

@datpn-1648
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants