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

Stabilize unit tests #228

Open
obecker opened this issue Sep 7, 2021 · 2 comments
Open

Stabilize unit tests #228

obecker opened this issue Sep 7, 2021 · 2 comments

Comments

@obecker
Copy link
Contributor

obecker commented Sep 7, 2021

When trying to contribute to this project, I was very surprised to see that a lot of unit tests are failing.

After digging into the code I realized that this results most probably from using current dates in the tests.
However, this is a problem because a year in reality has a different amount of millis depending on the current date, but a year in prettytime has always 31556925960 millis (about 365,242 days).
So current date minus 1 year will format as "one year ago" in a leap year (i.e. the duration contains the leap day),
but as "12 months ago" in all other years.

To fix this all tests should be based on defined dates, so they will produces the same results no matter when the tests are executed.

See the adjusted test in #229 as an example

@obecker
Copy link
Contributor Author

obecker commented Sep 7, 2021

I might also be useful to configure a github action that execute all tests after this issue has been fixed.
See https://docs.github.com/en/actions/quickstart
and https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven

@lincolnthree
Copy link
Member

Hey @obecker - You're 100% right. I'm about to be doing some PR work on this library (merges and such) to get caught up. If you're interested in contributing a patch that fixes this, I'd love to include it! It would be great to have more stable tests.

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

No branches or pull requests

2 participants