What is the best practice for automatically testing the correct behavior of a function that depends on the current year? Specifically, I would like to add a test to the function DateList in Mathics (a Mathematica-like CAS) that ensures that the current year is returned when no year is given as an argument. Two possible solutions come to my mind: Hard-code the current year in the test. So this test has to be updated every year with the potential of some failing integration tests after New Year. Create another function that is supposed to return the current year and ensure they return the same. This reduces the probability of errors but, of course, still both functions could be wrong. Any other ideas or pointers to existing practice?
I use the time on the server to get the current Date/Year and unit-test my unit that it returns the same year (which I got from the System Time) You should keep in mind the TimeZone difference when testing the returned value against the current Server DateTime. This works for my testing, and hope it helps you too.
Sending an email about thread groups in JMeter
Phoenix test data is persisting making the tests non-repeatable
Best Subset regression on test sample (after k-fold)
Unit testing a jee filter
Testing a component that appears repeatedly in the code - Test once per component, or per appearance?
XUnit DI through overridden Startup file (.net core)
How can I make Elixir mix test output more verbose?
Meteor test only runs one test suite
Stubbing static methods in MSpec
How i can order nunit TestFixtures
Cannot select a checkbox in codeception
Touch Screen Laptops Emulator for Testing
Gradle: automatically add a test dependency on a project
DbUnit Tests with SilkCentral
Running a test in golang that only works for some versions [duplicate]
How to redefine browser builtin variable to certain value to test a module?