woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
45 stars 21 forks source link

Add test coverage report #864

Closed nima-karimi closed 7 months ago

nima-karimi commented 3 years ago

Add a test coverage report for unit tests and include a check for Travis.

Some useful links:

tomalec commented 3 years ago

For the front-end tests/jest we can start with just --coverage, but I :+1: Coveralls

mikkamp commented 1 year ago

After updating to phpunit 9.5 in PR #1867, as long as we have a PHP version with xdebug installed then a coverage report can be produced as follows.

  1. Add the following section to phpunit.xml.dist

    <coverage>
        <include>
            <directory suffix=".php">./src</directory>
            <directory suffix=".php">./views</directory>
            <file>google-listings-and-ads.php</file>
        </include>
    </coverage>
  2. Setup tests: bin/install-wp-tests.sh <db_name> <db_user> <db_pass>

  3. Run the tests with a coverage report: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text

Example output: image

mikkamp commented 1 year ago

Update: A codecov report has been added in #1915 So far this only covers PHP, we also do unit testing in JS which we could include in the coverage report.