[test-improver] Add ConfigManager unit tests (16 edge-case tests)#76
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[test-improver] Add ConfigManager unit tests (16 edge-case tests)#76github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
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>
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Test Improver — automated AI assistant focused on improving tests.
Goal & Rationale
ConfigManagerhad zero unit tests despite having meaningful edge-case behaviour ingetInt()andgetBoolean(). 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 exceptiongetBooleanusesBoolean.parseBoolean, which only accepts"true"(case-insensitive) astrue. 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
ConfigManageris a non-resettable singleton, tests access its internalPropertiesfield via reflection to inject test values.@AfterEachremoves 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
Reproducibility
mvn test -Dtest=ConfigManagerTest -BAdd this agentic workflows to your repo
To install this agentic workflow, run