DATE INDEPENDENCE

From Test Automation Patterns
Jump to: navigation, search
.................................................................................................................Main Page / Back to Design Patterns / Back to Test Automation Patterns

Pattern summary

Write your test cases to be date independent

Category

Design

Context

Use this pattern if your test cases or your expected results have some dependency on dates

Description

If possible redesign your test cases (or expected results) to avoid [DATE DEPENDENCY]. If this is not possible, you must set the initial conditions accordingly

Implementation

Here some suggestions on how to implement this pattern:

  • ask developers to use the current date as default in the date fields, then you don't have to use it your scripts
  • calculate the dates that you need by adding or subtracting the wanted difference from the current date
  • in the setup procedure, set the system date to the date you are expecting (after you have saved the current date); after the test has been run set the current date back
  • in the expected results use only date & time differences and not the actual dates
  • ask developers to build a switch that you can use to block showing date & time on outputs
  • use for comparisons a tool that allows you to blot out the variable areas (date & time) on your outputs

Potential problems

If you have changed the system date and for some reason a test doesn't run through, your machine will be running on a wrong date and you may not notice it immediately

Issues addressed by this pattern

DATE DEPENDENCY

Experiences

If you have used this pattern and would like to contribute your experience to the wiki, please go to Feedback to submit your experience or comment.

.................................................................................................................Main Page / Back to Design Patterns / Back to Test Automation Patterns