How Do You Test Calendar Exceptions Together with Weekdays?
From the earlier reference collection. Read the current software blog.
Create a date that is active under the weekday calendar and explicitly removed by an exception, then verify the effective service result.
Model both sources of service
Weekly service rules and date-specific exceptions work together to determine whether a service runs on a particular date. A useful test chooses a date that matches the weekday pattern, then applies an exception that removes that service for the same date. This exposes implementations that read the weekly calendar but forget to apply the override.
Build the fixture so the weekday match is unambiguous. For example, define a service that runs Monday through Friday over a range that includes a chosen Tuesday, then add a removal exception for that Tuesday. The expected effective result is that this service is inactive on the selected date.
Test the opposite combination too
Add a companion case where the weekly pattern does not include a date but an explicit addition makes service active. Keeping both directions in the fixture checks that exceptions are applied as overrides, not treated as an extra filter that can only remove service.
Use a stable date and an explicit service identifier so the assertion can name the exact service being evaluated. If multiple services exist, ensure the test distinguishes them; an unrelated active service could otherwise make a route-level result look correct even when the target service’s exception was ignored.
Check boundaries and precedence
Test a date at the beginning or end of the weekly calendar range and a nearby date outside it. This helps catch inclusive-versus-exclusive range mistakes. Also verify that an exception for one service does not affect another service using the same date.
Keep date arithmetic controlled and independent of the host’s current time zone. The feature under test is calendar membership and exception precedence, so ambient clock settings should not shift the selected date. A small table of expected service IDs by date can make the intended combinations easy to review.
Assert the result users see
Where possible, test the final trip or departure query, not just a helper that computes service activation. A calendar unit can pass while the schedule lookup fails to join the resulting service IDs correctly. Include one trip attached to the target service so the test can verify that it is absent on the removed date and present on the added date.
The complete test demonstrates a clear rule: weekday membership establishes the regular pattern, while a matching date exception changes the effective outcome for that service. That rule should remain visible in both fixture data and assertion names.