testing


Year-dependent test


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.

Related Links

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

Categories

HOME
yii2
variables
nullpointerexception
hashmap
bpmn
bookshelf.js
sqlite3
v8
dxl
icloud
datastax-java-driver
basic
windows-10-universal
nano-server
kentor-authservices
u-sql
modelica
timeout
vb.net-2010
quartz-scheduler
uitypeeditor
dosgi
openrefine
aurigma
oxyplot
viewport
realex-payments-api
django-storage
traffic
applozic
minitab
strncpy
replaceall
log4js-node
jaxb2
quote
gsoap
lxd
gammu
ghost4j
rotational-matrices
bytecode-manipulation
swisscomdev
sqlite2
webdriver-manager
powershell-dsc
botbuilder
acoustics
.net-4.6.2
sas-jmp
angular2-meteor
long-polling
powercli
veracode
csound
dtexec
hittest
query-performance
jquery-filter
instant
passport-google-oauth
thrust
essence
associative-array
cloudbees
uid
historian
r-tree
icu4j
feedback
deis
cakephp-3.1
ibaction
sankey-diagram
apache-commons-fileupload
fluid-dynamics
nsbutton
flask-cors
android-radiobutton
p4java
wp-query
reactfx
mysql-error-1062
oracle-warehouse-builder
message-driven-bean
ruby-datamapper
dbconnection
dotnetnuke-5
chronoforms
drools-planner
free-variable
e4x
frameset
osql
assembly-loading
gnustep
rfc1123
javax.script
radcombobox
gin
ubuntu-9.04

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App