google-listings-and-ads icon indicating copy to clipboard operation
google-listings-and-ads copied to clipboard

test_disable_promotion failing locally

Open martynmjones opened this issue 1 year ago • 2 comments

Describe the bug:

When running the GLA unit tests locally test_disable_promotion in WCCouponAdapterTest is failing because of unexpected datetimes. Tests are all passing on GH so this is not a high-priority issue but may need to be investigated further.

Screenshot 2023-03-31 at 15 17 00

Expected behavior:

Tests should pass regardless of the environment they are run in.

martynmjones avatar Mar 31 '23 14:03 martynmjones

I'm not able to reproduce this failure, although it might be related to a specific time of day since it uses gmdate( DATE_ATOM ).

However one thing I noticed is that all data providers (search for @dataProvider) will run regardless of what the filter is set to. For this specific test that won't make too much difference but it will take longer to run because it creates a whole host of test products. A better way to run just that specific test is:

vendor/bin/phpunit tests/Unit/Coupon/WCCouponAdapterTest.php --filter=test_disable_promotion

mikkamp avatar Jun 15 '23 13:06 mikkamp

There was a recent failure of this same test, although there was a difference of only 1 second: https://github.com/woocommerce/google-listings-and-ads/actions/runs/10562298192/job/29259970597

image

I haven't looked into all the details, but it seems using gmdate( DATE_ATOM ) twice could potentially be a different timestamp then when the actual code is run. Should find a better way to compare those dates, or use a generated date for the test data, so we can confirm it's always the same.

mikkamp avatar Aug 26 '24 15:08 mikkamp