Hi guys, I have a scheduled task I'm trying to write a Spek test for. The task calls different apis at sunset and sunrise. I have written tests that execute at sunset and sunrise by setting the calendar and executing the function once in the task but I need to test the transition so need.
How can I execute the task in my test to check the transition from sunset to sunrise whilst maintaining state within the task?
I've sorted it now.
11/12/2019, 6:56 PM
What was your solution?
11/13/2019, 9:45 AM
The Issue I was having was around mocking Calendar.getInstance since I needed to get the time of sunset and sunrise. I used MockK to answer two different times for Calendar.getInstance() based on a flag I set in my test. This allowed me to run the test at sunset and then run the test at sunrise.