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

Add <whitelist /> to the phpunit.xml.dist to support code coverage #47

Open
mcspronko opened this issue Sep 18, 2019 · 4 comments
Open
Labels
good first issue Good for newcomers

Comments

@mcspronko
Copy link
Owner

No description provided.

@mcspronko mcspronko added the good first issue Good for newcomers label Sep 18, 2019
@underser
Copy link

Hi @mcspronko ,
could you please describe where phpunit.xml.dist is located in the repository?
and what adding should resolve?

@mcspronko
Copy link
Owner Author

Hi @underser
The phpunit.xml.dist can be located under the individual extension in the repository e.g. card, card-gateway directory. Once the file added, the node should be added and the list of extension related directories e.g. "Setup", "Gateway" etc. should be listed.

In this way, we can run a code coverage tool and get the test coverage report.

Let me know if you have questions.

@underser
Copy link

@mcspronko thank for quick response
So for card-gateway it should be something like this:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
         colors="true"
         backupGlobals="false"
        >

    <testsuite name="Liqpay gateway tests">
        <directory suffix="Test.php">Test/Integration</directory>
    </testsuite>

    <php>
        <ini name="date.timezone" value="America/Los_Angeles"/>
        <ini name="xdebug.max_nesting_level" value="200"/>
    </php>

    <filter>
        <whitelist addUncoveredFilesFromWhiteList="true">
            <directory suffix=".php">../*</directory>
            <exclude>
                <directory>../admin</directory>
                <directory>../api</directory>
                <directory>../cart-admin</directory>
                // List of all directories in root
            </exclude>
        </whitelist>
    </filter>
</phpunit>

btw, it still doesn't clear for me:

  1. How to test this on local?
  2. What coverage report you want to get from this in the feature? I guess that this is for something like Travis, no?

@mcspronko
Copy link
Owner Author

Hi @underser, yes, however a phpunit.xml.dist file should be created for each Magento 2 extension/directory. Meaning, the card-gateway should have its own phpunit.xml.dist and the whitelist configuration should only relate to card-gateway directory and so on.

You can test it locally by running the command inside card-gateway directory:

vendor/bin/phpunit Test --coverage-text=coverage_report.txt

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

No branches or pull requests

2 participants