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.
Some questions about TestComplete
How to test a function that's using a Client API function imported from another module?
How do I “stub” a child ember component in an integration test?
How to test angular2 dynamic routes
play 2.5 render view test, access to flash messages
TFS SQL Server Report builder - Trouble finding Test plan ID parameter syntax
Seeing which elements are available on the page when using Capybara and RSpec
What is the best way for testing asynchronous react component
A/B split testing in sitecore without DMS [closed]
Issues detecting textboxes that get generated via a template
how to test system.media.SoundPlayer
Spock Mock internal Date object
Custom testify output for failing test of xml / strings
Ember testing components that have helpers that use services
Extending existing type testing.T for adding extra checks
Promise isn't working in react component when testing component using jest