-
-
Notifications
You must be signed in to change notification settings - Fork 713
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
isEqualTo on date can lead to unexpected failures when switching time zones #3382
Comments
Thanks for reporting this @wimdeblauwe, we will have a look at it shortly. |
AssertJ uses various date format to get parse the date from the given string, in the test case, it is the AssertJ delegates the parsing to My understanding is that the parsing has to use the default timezone because Passing string instead of date was added to avoid building dates by hand which was pain before java 8, it"s now less useful with the new date/time API which provides a bunch of factory methods. @wimdeblauwe what behavior would you have liked to see here? |
@wimdeblauwe FYI, we"ll evaluate the internal usage of Any input you may provide us on expected behavior can help us ensure we don"t go off-track 🙂 |
I agree, but shouldn"t it keep working when you switch the default timezone ? It feels like some kind of caching is done and the updated default timezone is not taken into account. |
Indeed this is bug in AssertJ, we store default date formats as The problem arises when you change the timezone, the default date formats have already been created with the previous timezone and thus interprets incorrectly the dates as string, (evil stateful well spotted @wimdeblauwe ! |
Thanks @joel-costigliola . That is great with open-source, you can get a peek "inside" to guess what might be issue. Actually solving it is usually a step harder :-) |
…efault timezone or the lenient flag changes. Fix assertj#3382
Describe the bug
The behaviour of
isEqualTo(String)
when asserting a java.util.Date can fail if you switch the default time zone during a test run.Test case reproducing the bug
Add a test case showing the bug that we can run
Run this test with the code commented out. The test will be ok.
Now enable the code in comments and run the test again. The test
testWithIsEqualTo
now fails, but on the part that was already active before.(I found the issue with using @DefaultTimeZone, but I can reproduce it without it, so I believe it might be an AssertJ issue).
The text was updated successfully, but these errors were encountered: