Mocking time in mysql

679 Views Asked by At

Problem: I am currently using Time Cop gem for mocking time in cucumber test cases. There is one test case that is getting failed because of MySQL is not getting the time set by Time Cop.

Lets say. System date is = Jan 21 2015 After Time Cop = Feb 01 2015 By inside MySQL

SELECT CURDATE();

This query returns "Jan 21 2015". Hence the test was failing.

So this brings to my questions.

  1. Is it a good practice to mock time in test cases?
  2. How to make sure that if time is mocked then MySQL is also receiving the same time?
0

There are 0 best solutions below