Skip to content

[test-improver] Add tests documenting addBusinessDays weekend-skipping bug#49

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/addBusinessDays-tests-4b22c7c2bb3a7713
Draft

[test-improver] Add tests documenting addBusinessDays weekend-skipping bug#49
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/addBusinessDays-tests-4b22c7c2bb3a7713

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

🤖 Test Improver — automated AI assistant focused on improving tests.

Goal & Rationale

DateUtils.addBusinessDays has a well-known but completely untested bug: it skips day-of-week 6 (FRIDAY) and 7 (SATURDAY) instead of 7 (SATURDAY) and 1 (SUNDAY). This means:

  • Friday is wrongly treated as a non-business day
  • Sunday is wrongly treated as a business day

A task with a Monday deadline, created on Thursday, would schedule to Sunday — a day outside business hours. Without tests, this bug is invisible in CI and will likely regress after any refactoring.

Approach

7 tests added to DateUtilsTest, covering three categories:

Correct-behaviour tests (pass with both buggy and fixed code)

Test Start Days Expected result
testAddBusinessDays_zeroDays_returnsSameDay Monday 0 Monday
testAddBusinessDays_mondayPlusOne_returnsTuesday Monday 1 Tuesday
testAddBusinessDays_mondayPlusThree_returnsThursday Monday 3 Thursday
testAddBusinessDays_mondayPlusFive_returnsMonday Monday 5 Next Monday

Bug-pin tests (pass now; need updating when bug is fixed)

Test Start Days Buggy result (current) Correct result
testAddBusinessDays_thursdayPlusOne_BUG Thursday 1 Sunday Friday
testAddBusinessDays_fridayPlusOne_BUG Friday 1 Sunday Monday
testAddBusinessDays_mondayPlusFour_BUG Monday 4 Sunday Friday

Bug-pin tests assert the current (wrong) value so the tests pass today and protect against silent regression. When the bug is fixed the assertEquals in each _BUG test must be updated to the "Correct result" value shown above — the comment in each test specifies this.

Test Status

Tests run: 45, Failures: 1, Errors: 1, Skipped: 7

Pre-existing failures (not caused by this PR):

All 7 new tests pass.

Coverage Impact

No coverage tooling in CI yet (Issue #26 / Issue #47 tracks adding JaCoCo). The addBusinessDays method had zero test coverage before; it now has 7 tests exercising multiple paths through the method.

Trade-offs

Reproducibility

mvn test -B
# New tests are in DateUtilsTest — look for testAddBusinessDays_*

Generated by Test Improver · 143.4 AIC · ⌖ 10.4 AIC · ⊞ 10.9K ·
Comment /test-assist to run again

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/test-improver.md@1c6668b751c51af8571f01204ceffb19362e0f66

DateUtils.addBusinessDays skips day-of-week 6 (FRIDAY) and 7 (SATURDAY)
instead of 7 (SATURDAY) and 1 (SUNDAY).  This means:
  • Friday is wrongly treated as a non-business day
  • Sunday is wrongly treated as a business day

Adds 7 tests:
  • 3 tests for cases where buggy and correct implementations agree
    (Mon+0, Mon+1, Mon+3, Mon+5)
  • 3 "_BUG" tests that pin the current wrong output so the bug cannot
    regress silently: Thu+1→SUN (correct=FRI), Fri+1→SUN (correct=MON),
    Mon+4→SUN (correct=FRI)

When the bug is fixed the _BUG assertions should be updated to the
correct day-of-week values noted in the test comments.

Pre-existing failures unchanged: DateUtilsTest.testGetQuarter (Issue #6),
TaskServiceTest.testGetTaskStatistics (Issue #3).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants