Skip to content

Collapse duplicate-model tests into one parameterized test - #651

Merged
slachiewicz merged 1 commit into
masterfrom
agent/sweep-modello-duplicate-model-tests
Nov 18, 2026
Merged

slachiewicz merged 1 commit into
masterfrom
agent/sweep-modello-duplicate-model-tests

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

The three duplicate-model tests repeated the same try/catch/fail boilerplate
and differed only in the model file and expected message. junit-jupiter-params
is already a test dependency of modello-core, so one CsvSource-driven test with
assertThrows expresses all three cases directly.

Area: modello-core test sources only; production code is untouched.

Changes:

  • Replaced modelWithDuplicateClasses, modelWithDuplicateFields and
    modelWithDuplicateAssociations with one @ParameterizedTest / @CsvSource
    method modelWithDuplicateMember(modelFile, expectedMessage).
  • Used assertThrows(ModelloRuntimeException.class, ...) + assertEquals on
    the message; removed the now-unused fail import.
  • All three original model files and expected messages are preserved verbatim.

Verification (JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home):

  • mvn -B -o spotless:apply / mvn -B -o spotless:check - both BUILD SUCCESS
  • mvn -B -o test - BUILD SUCCESS, 178 tests run, 0 failures/errors/skips
  • test-summary.py --classes before/after: modello-core 73 -> 73 tests,
    DefaultModelloCoreTest 4 -> 4, 0 classes lost tests
  • Mutation check: changing one CsvSource expected message in a scratch copy
    failed exactly 1 of 4 tests (Tests run: 4, Failures: 1); restored from the
    saved copy. The refactored assertion is therefore live, not vacuous.

The three duplicate-model cases used identical try/catch/fail boilerplate
differing only in model file and expected message. A single CsvSource-driven
test keeps all three cases while making the assertions uniform and the
intent easier to read.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean consolidation — assertThrows + @CsvSource is exactly the right JUnit 5 idiom for this pattern. All three cases are preserved verbatim, the assertions are live (mutation-tested per the PR description), and there are no production-code changes.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@slachiewicz
slachiewicz merged commit c228c6d into master Nov 18, 2026
11 checks passed
@slachiewicz
slachiewicz deleted the agent/sweep-modello-duplicate-model-tests branch November 18, 2026 22:26
@slachiewicz slachiewicz added the maintenance Cleanup, refactoring or other internal change label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Cleanup, refactoring or other internal change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants