Skip to content

[test-improver] Add ConfigManager unit tests (16 edge-case tests)#76

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/configmanager-edge-case-tests-9782ef5a02b957aa
Draft

[test-improver] Add ConfigManager unit tests (16 edge-case tests)#76
github-actions[bot] wants to merge 1 commit into
mainfrom
test-assist/configmanager-edge-case-tests-9782ef5a02b957aa

Conversation

@github-actions

Copy link
Copy Markdown

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

Goal & Rationale

ConfigManager had zero unit tests despite having meaningful edge-case behaviour in getInt() and getBoolean(). These methods silently return default values on invalid input — the behaviour is correct but was completely untested.

Key non-obvious behaviours that are now pinned:

  • getInt("key", default) with a decimal ("3.14") or empty string returns the default — no exception
  • getBoolean uses Boolean.parseBoolean, which only accepts "true" (case-insensitive) as true. Values like "yes" and "1" return false, not true — a common gotcha.

Approach

16 pure unit tests using @ExtendWith(MockitoExtension.class) — no Spring context needed.

Because ConfigManager is a non-resettable singleton, tests access its internal Properties field via reflection to inject test values. @AfterEach removes those keys to prevent cross-test pollution.

Coverage Impact

No baseline numbers (JaCoCo not yet configured on main). All 16 new tests pass; zero pre-existing regressions.

Test Status

Tests run: 16, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Reproducibility

mvn test -Dtest=ConfigManagerTest -B

Generated by Test Improver · 99.1 AIC · ⌖ 9.62 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

Tests cover:
- get(): missing key → null, present key → value
- get(key, default): missing/present key with default
- getInt(): missing key, valid int, negative int, non-numeric,
  decimal, empty string — all return default or parsed value
- getBoolean(): missing key, "true"/"TRUE" → true, "false" → false,
  "yes"/"1" → false (Boolean.parseBoolean only accepts "true")

Uses reflection to inject test values into the singleton's
Properties field; @AfterEach removes test keys to avoid pollution.

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