Skip to content

[test-improver] Add bug-pin tests for Project model (getProgress + getMemberIds)#68

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/project-model-bug-pin-tests-98e4943f91a141b4
Draft

[test-improver] Add bug-pin tests for Project model (getProgress + getMemberIds)#68
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/project-model-bug-pin-tests-98e4943f91a141b4

Conversation

@github-actions

Copy link
Copy Markdown

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

Goal & Rationale

Project is a core domain model used across controllers and services, yet had zero unit tests. Two of its methods have documented bugs that could silently break after refactoring:

Method Bug
getProgress() Division by zero when taskCount == 0 — returns NaN instead of 0.0
getMemberIds() NPE when members is null (field not set in constructor)
getMemberIds() NumberFormatException when IDs have whitespace padding (e.g. "1, 2, 3")

This PR pins those bugs so they cannot be silently swallowed by future changes.

Approach

Pure POJO unit tests — no Spring context, no H2, completes in ~60ms:

  • 9 tests in ProjectTest.java
  • Bug-pin tests (3) use assertThrows to document currently broken behaviour with clear BUG messages
  • Happy-path tests (5) verify the correct behaviour that works today
  • Whitespace-comma test updated after discovering Java's String.split(",") drops trailing empty tokens (not a bug — documented as safe behaviour)

Coverage Impact

Class Before After
Project ~0% (no tests) ~50%+ (getProgress + getMemberIds paths)

Trade-offs

  • Tests reflect current buggy behaviour. When bugs are fixed, the assertThrows tests should be updated to verify the corrected behaviour.
  • No new dependencies.

Reproducibility

mvn test -Dtest=ProjectTest -B
# Tests run: 9, Failures: 0, Errors: 0

Test Status

✅ All 9 new tests pass.
✅ No regressions — pre-existing failures (Bug #3 DateUtils, Bug #6 TaskService) are unchanged.

Generated by Test Improver · 93.2 AIC · ⌖ 9.75 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

Documents known bugs:
- getProgress() returns NaN when taskCount == 0 (division by zero)
- getMemberIds() throws NPE when members field is null
- getMemberIds() throws NumberFormatException on whitespace-padded IDs

Also documents safe/correct behaviour (valid inputs, trailing comma).
9 tests total; all pass.

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