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

MetricsTest: fix tests failing on imprecise floats #344

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented May 25, 2022

This solves the following test failures (master is currently failing on a number of PHP versions):

1) PhpCoveralls\Tests\Bundle\CoverallsBundle\Entity\MetricsTest::shouldHaveLineCoverageOnConstructionWithCoverage
Failed asserting that 66.66666666666666 is identical to 66.66666666666667.

/home/runner/work/php-coveralls/php-coveralls/tests/Bundle/CoverallsBundle/Entity/MetricsTest.php:86
phpvfscomposer:///home/runner/work/php-coveralls/php-coveralls/vendor/phpunit/phpunit/phpunit:97

2) PhpCoveralls\Tests\Bundle\CoverallsBundle\Entity\MetricsTest::shouldMergeThatWithEmptyMetrics
Failed asserting that 66.66666666666666 is identical to 66.66666666666667.

/home/runner/work/php-coveralls/php-coveralls/tests/Bundle/CoverallsBundle/Entity/MetricsTest.php:102
phpvfscomposer:///home/runner/work/php-coveralls/php-coveralls/vendor/phpunit/phpunit/phpunit:97

3) PhpCoveralls\Tests\Bundle\CoverallsBundle\Entity\MetricsTest::shouldMergeThat
Failed asserting that 66.66666666666666 is identical to 66.66666666666667.

/home/runner/work/php-coveralls/php-coveralls/tests/Bundle/CoverallsBundle/Entity/MetricsTest.php:116
phpvfscomposer:///home/runner/work/php-coveralls/php-coveralls/vendor/phpunit/phpunit/phpunit:97

Note: this adds a polyfill to handle a new PHPUnit assertion. Alternatively, you could choose to add the PHPUnit Polyfills as a dependency instead. This would allow to use the official method name from PHPUnit.

Refs:

@jrfnl jrfnl force-pushed the feature/tests-fix-tests-checking-imprecise-floats branch from 25b25fe to 8f36575 Compare August 25, 2022 23:17
This solves the following test failures (`master` is currently failing on a number of PHP versions):
```
1) PhpCoveralls\Tests\Bundle\CoverallsBundle\Entity\MetricsTest::shouldHaveLineCoverageOnConstructionWithCoverage
Failed asserting that 66.66666666666666 is identical to 66.66666666666667.

/home/runner/work/php-coveralls/php-coveralls/tests/Bundle/CoverallsBundle/Entity/MetricsTest.php:86
phpvfscomposer:///home/runner/work/php-coveralls/php-coveralls/vendor/phpunit/phpunit/phpunit:97

2) PhpCoveralls\Tests\Bundle\CoverallsBundle\Entity\MetricsTest::shouldMergeThatWithEmptyMetrics
Failed asserting that 66.66666666666666 is identical to 66.66666666666667.

/home/runner/work/php-coveralls/php-coveralls/tests/Bundle/CoverallsBundle/Entity/MetricsTest.php:102
phpvfscomposer:///home/runner/work/php-coveralls/php-coveralls/vendor/phpunit/phpunit/phpunit:97

3) PhpCoveralls\Tests\Bundle\CoverallsBundle\Entity\MetricsTest::shouldMergeThat
Failed asserting that 66.66666666666666 is identical to 66.66666666666667.

/home/runner/work/php-coveralls/php-coveralls/tests/Bundle/CoverallsBundle/Entity/MetricsTest.php:116
phpvfscomposer:///home/runner/work/php-coveralls/php-coveralls/vendor/phpunit/phpunit/phpunit:97
```

Note: this adds a polyfill to handle a new PHPUnit assertion. Alternatively, you could choose to add the [PHPUnit Polyfills](https://github.com/Yoast/PHPUnit-Polyfills) as a dependency instead. This would allow to use the _official_ method name from PHPUnit.

Refs:
* https://floating-point-gui.de/
* https://phpunit.readthedocs.io/en/9.5/assertions.html#assertequalswithdelta
* https://github.com/Yoast/PHPUnit-Polyfills
@jrfnl jrfnl force-pushed the feature/tests-fix-tests-checking-imprecise-floats branch from 8f36575 to 1f392d8 Compare August 25, 2022 23:18
@jrfnl
Copy link
Contributor Author

jrfnl commented Aug 25, 2022

Rebased without changes to see if I could trigger a CI build.

@keradus
Copy link
Member

keradus commented Aug 29, 2022

Thanks!

@keradus keradus merged commit 24a4c8a into php-coveralls:master Aug 29, 2022
@jrfnl jrfnl deleted the feature/tests-fix-tests-checking-imprecise-floats branch August 29, 2022 08:50
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

Successfully merging this pull request may close these issues.

2 participants