Difference between revisions of "DATE INDEPENDENCE"

From Test Automation Patterns
Jump to navigation Jump to search
m (Put topic titles in capital letters)
Line 8: Line 8:
 
=<span style="font-size: 16px">'''Description'''</span>=
 
=<span style="font-size: 16px">'''Description'''</span>=
 
<span style="font-size: 16px">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</span>
 
<span style="font-size: 16px">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</span>
=<span style="font-size: 16px">Implementation</span>=
+
=<span style="font-size: 16px">'''Implementation'''</span>=
 
<span style="font-size: 16px">Here some suggestions on how to implement this pattern:</span><br />  
 
<span style="font-size: 16px">Here some suggestions on how to implement this pattern:</span><br />  
 
* <span style="font-size: 16px">ask developers to use the current date as default in the date fields, then you don't have to use it your scripts</span>
 
* <span style="font-size: 16px">ask developers to use the current date as default in the date fields, then you don't have to use it your scripts</span>
Line 18: Line 18:
 
=<span style="font-size: 16px">'''Potential problems'''</span>=
 
=<span style="font-size: 16px">'''Potential problems'''</span>=
 
<span style="font-size: 16px">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</span>
 
<span style="font-size: 16px">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</span>
=<span style="font-size: 16px">Issues addressed by this pattern</span>=
+
=<span style="font-size: 16px">'''Issues addressed by this pattern'''</span>=
 
''<span style="font-size: 16px">[[DATE DEPENDENCY]]</span>''
 
''<span style="font-size: 16px">[[DATE DEPENDENCY]]</span>''
 
=<span style="font-size: 16px">'''Experiences'''</span>=
 
=<span style="font-size: 16px">'''Experiences'''</span>=
 
<span style="font-size: 16px">If you have used this pattern, please add your name and a brief story of how you used this pattern: your context, what you did, and how well it worked - or how it didn't work!</span><br /> <span style="font-size: 14px">.................................................................................................................[[Main Page]] / Back to [[Design Patterns]] / Back to [[Test Automation Patterns]]</span></div>
 
<span style="font-size: 16px">If you have used this pattern, please add your name and a brief story of how you used this pattern: your context, what you did, and how well it worked - or how it didn't work!</span><br /> <span style="font-size: 14px">.................................................................................................................[[Main Page]] / Back to [[Design Patterns]] / Back to [[Test Automation Patterns]]</span></div>

Revision as of 14:37, 26 June 2018

.................................................................................................................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, please add your name and a brief story of how you used this pattern: your context, what you did, and how well it worked - or how it didn't work!
.................................................................................................................Main Page / Back to Design Patterns / Back to Test Automation Patterns