Case Study: Stabilize E2E Automated Tests That Execute on All Dates
A simple tip for running date-related automated tests.
Today (2025–07–05, Sunday), at home, I ran one automated test against the WhenWise app. It failed.
The WhenWise screen (below) in the browser.
That specific appointment ‘甲班’ was not there. (By the way, my father creates opportunities for me to practice Chinese — and now even Japanese — at home. He’s also learning Japanese himself.)
I clearly remember this test execution passed on another day.
I perused the test scripts (readability is a key for successful test automation), and realized that the event was created the next day, and today is Sunday.
I clicked the “Next week” button on the WhenWise calendar, and there it is.
After understanding the cause, the fix is easy: adding checking for today = Sunday? Then, go to the next week.
calendar_page.click_week_view
if Date.today.wday == 0 # sunday
calendar_page.click_next
end
calendar_page.click_event_with_title("甲班")
Rerun the test in TestWise. It passed.
Lessons Learned:
Automated tests involving dates should be verified across a variety of days, especially edge cases like Mondays, Sundays, and the first and last days of a month.
Test scripts must be dynamic.
Readability in end-to-end (E2E) test scripts is essential for long-term collaboration and troubleshooting.
Ruby’s date operations are both powerful and elegant. For example, expressions like
1.day.ago
are concise and highly readable.
Related reading: