A small reservation component. Given a room's bookings and the day's business hours,
AvailabilityCalculator.freeSlots computes when the room is free. It is the code you
work in for Lab 2.
It ships with a generated test suite that passes, and a property-based test harness (jqwik) with one example property. Everything is green. Your job in Lab 2 is to decide whether green actually means correct.
Read ARCHITECTURE.md before the code.
mvn test
mvn test runs both files, the ordinary example-based tests (AvailabilityCalculatorTest)
and the property-based tests (AvailabilityProperties). A code-coverage report is written
to target/site/jacoco/index.html.
This repository has CI configured in .github/workflows/ci.yml. GitHub disables workflows on a
fresh fork, so enable them once on your fork (the handout shows where). After that, every
push runs mvn test. You will watch the gate go red when your new property finds the bug, then
green once you fix it.
- Component:
src/main/java/edu/cmu/cs214/availability/ - Example-based tests:
src/test/java/edu/cmu/cs214/availability/AvailabilityCalculatorTest.java - Property-based tests:
src/test/java/edu/cmu/cs214/availability/AvailabilityProperties.java - Setup:
SETUP.md
See the Lab 2 handout on the course page for the three milestones you show a TA.
- Observability gap: The test suite did not fully encode the definition of correct availability. It checked that reported free slots were valid, but not that every minute of the business day was covered exactly once by either a booking or a returned free slot.
- Controllability gap: The example tests did not include an empty booking list or a final booking that ended before
dayEnd. Therefore, they did not drive the input that exposes the missing trailing free interval. - Observability gap:
returnedSlotsNeverOverlapABookingcan pass whenfreeSlotsreturns too few slots, or even no slots, because it only inspects the slots that were returned. It does not compare the result against the expected coverage of the whole business day.
- Because high coverage does not equate to a function being correct. In other words, high coverage "is not job done." Also, coverage means that the code ran, not that each possible edge case was detected.