Skip to content

[test-improver] Add missing tests for DateUtils.isOverdue/isWithinRange/daysBetween and StringUtils.padRight#44

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/dateutils-stringutils-missing-coverage-5d51c8d32ff5a1ae
Draft

[test-improver] Add missing tests for DateUtils.isOverdue/isWithinRange/daysBetween and StringUtils.padRight#44
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/dateutils-stringutils-missing-coverage-5d51c8d32ff5a1ae

Conversation

@github-actions

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

Copy link
Copy Markdown

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

Goal & Rationale

DateUtils had three methods (isOverdue, isWithinRange, daysBetween) with zero test coverage, and StringUtils.padRight had no tests at all despite a known crash bug. These methods are used in real business logic (overdue detection, task scheduling, reporting). Adding tests here prevents silent regressions when the code is eventually fixed or refactored.

Approach

  • DateUtils.isOverdue — added 4 tests covering: past date (→ true), far future (→ false), null input (→ false, by design), and unparseable string (→ false, documents silent-failure behaviour).
  • DateUtils.isWithinRange — added 3 tests: middle-of-range, before-start, after-end.
  • DateUtils.daysBetween — added 2 tests: exact 7-day span, same instant (→ 0).
  • StringUtils.padRight — added 4 tests: string shorter than width (happy path), string equal to width, null input, and a assertThrows(NegativeArraySizeException.class, ...) test that documents and pins the known crash bug (Issue 🟠 [BUG] StringUtils.padRight() throws StringIndexOutOfBoundsException #7). When the bug is fixed, that last assertion should be replaced with the correct expected output.

No production code was changed. No new dependencies added.

Coverage Impact

Class Tests before Tests after
StringUtilsTest 10 14
DateUtilsTest 8 17

No coverage tooling is wired into CI yet (Issue #26 tracks adding JaCoCo). Line-count numbers above are approximations.

Trade-offs

  • The testPadRight_stringLongerThanWidth_throwsBug test intentionally documents a bug rather than correct behaviour — it will need updating when Issue 🟠 [BUG] StringUtils.padRight() throws StringIndexOutOfBoundsException #7 is resolved.
  • addBusinessDays was left untested: the implementation skips Friday+Saturday instead of Saturday+Sunday, so any meaningful test would immediately fail. A separate issue should drive that fix.

Test Status

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

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

All new tests pass:

[INFO] Tests run: 14, Failures: 0, Errors: 0, Skipped: 0  ← StringUtilsTest
[ERROR] Tests run: 17, Failures: 1, Errors: 0, Skipped: 1  ← DateUtilsTest (1 pre-existing failure)

Reproducibility

mvn test -B -Dmaven.repo.local=~/.m2

Generated by Test Improver · 107.5 AIC · ⌖ 10.1 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

Add tests for previously untested DateUtils methods:
- isOverdue (past, future, null, invalid date string)
- isWithinRange (middle, before-start, after-end)
- daysBetween (exact week, same instant)

Add padRight tests to StringUtils:
- Happy paths (shorter, equal, null input)
- Document known NegativeArraySizeException bug (Issue #7)
  via assertThrows so the bug is not silently ignored

Pre-existing failures unrelated to these changes:
- DateUtilsTest.testGetQuarter: off-by-one bug (Issue #6)
- TaskServiceTest.testGetTaskStatistics: division by zero (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