Skip to content

test: split processor tests into the modules they cover - #401

Merged
AndreasIgel merged 13 commits into
java-helpers:mainfrom
igel-devin-ai:devin/1794429896-issue-390-module-tests
Nov 16, 2026
Merged

AndreasIgel merged 13 commits into
java-helpers:mainfrom
igel-devin-ai:devin/1794429896-issue-390-module-tests

Conversation

@igel-devin-ai

Copy link
Copy Markdown
Contributor

Closes #390.

Each extracted codegen module now proves its behavior with tests in its own module, without simple-builder types.

Test moves

Test From To
JavaLangAnalyserTest (26) processor simple-processor
OptionValueParsersTest (7) processor simple-processor
ProcessorOptionRegistryTest (2) processor simple-processor
CodegenProcessorConfigurationTest (1) processor simple-processor
ElementCollectorTest (1) processor simple-processor
MinimalCodegenProcessorTest (1) processor simple-processor — exercises AbstractCodegenProcessor end-to-end without builder types
ActivePerformanceTrackerTest (25) processor codegen-core — uses a local capturing logger, since codegen-testing would be a dependency cycle
FormatterProfileTestUtilsTest (2) processor codegen-testing — a minimal eclipse-java-format.xml test resource stands in for the bundled codegen-roaster profile
RoasterCodeGeneratorResilienceTest (2) processor codegen-roaster — environment rebuilt from codegen-core/codegen-testing types

New tests

  • simple-processor: JavaLangMapperTest and FieldAnnotationExtractorTest, driven by a probe processor capturing live TypeElement/VariableElements from a real compilation.
  • codegen-roaster: RoasterCodeGeneratorTest passes generic GenerationTargetClassDtos directly and asserts the whole generated source as a text block (ProcessorAsserts.assertNormalizedEquals).
  • codegen-core: SinkProcessingLoggerTest (flat vs. hierarchical output), CodegenEnumsTest, ImportCollectorTest — plain JUnit.
  • codegen-testing: CapturingProcessingLoggerTest, CodegenTestUtilsTest, ProcessingEnvironmentStubTest, ProcessorAssertsTest.

Dependency cut

processor no longer depends on codegen-roaster — the only main-code mention was a javadoc reference in BuilderDefinitionCreator, now kept as plain text. codegen-roaster arrives transitively through simple-processor.

Coverage, measured per module on its own (mvn clean install -Pmetrics)

Module Own line coverage
codegen-core 91%
simple-processor 50%
codegen-roaster 62%
codegen-testing 56%
processor 98%

The project total stays at the Codecov 80% target because Codecov reads the aggregate, where the generic modules remain covered by the simple-builder tests too; the per-module numbers now make each module's own proof visible.

…#390)

Move every test that exercises a shared codegen module into that
module so each module proves its behavior with tests in its own tree:

- simple-processor: JavaLangAnalyserTest, OptionValueParsersTest,
  CodegenProcessorConfigurationTest, ProcessorOptionRegistryTest,
  ElementCollectorTest and MinimalCodegenProcessorTest (now compiling
  against CodegenTestUtils directly), plus new JavaLangMapperTest and
  FieldAnnotationExtractorTest driving a probe processor
- codegen-core: ActivePerformanceTrackerTest (with a local capturing
  logger, as codegen-testing would be a dependency cycle), plus new
  SinkProcessingLoggerTest, CodegenEnumsTest and ImportCollectorTest;
  jackson-databind added as test-scoped dep for the tracker's JSON
  assertions
- codegen-testing: FormatterProfileTestUtilsTest plus new tests for
  CapturingProcessingLogger, CodegenTestUtils, ProcessingEnvironmentStub
  and ProcessorAsserts; a minimal eclipse-java-format.xml test resource
  stands in for the bundled codegen-roaster profile
- codegen-roaster: RoasterCodeGeneratorResilienceTest rebuilt on a
  GenerationEnvironment stub of codegen-core types, plus new
  RoasterCodeGeneratorTest asserting whole generated sources against
  generic DTOs

processor no longer depends on codegen-roaster: the only main-code
mention was a javadoc reference, now kept as plain text. Each module's
metrics profile reports coverage from its own tests alone (e.g.
codegen-core 91% lines, processor 98%).
@AndreasIgel

This comment has been minimized.

- add missing coverage for codegen-testing helpers, codegen-roaster
  backend/mapper/generator and simple-processor analysers, context,
  options and logging
- move shared test support into codegen-testing (ProbeProcessor,
  ElementTestUtils, TestingGenerationEnvironment)
- delete enum-only test and exclude enums/DTO model packages from
  JaCoCo coverage scope in all modules
- pin surefire 3.6.0 in core so JUnit 5 tests actually run

Per-module line coverage now: core 95%, codegen-core 90%,
codegen-roaster 91%, codegen-testing 91%, simple-processor 84%,
processor 97%.

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
@igel-devin-ai

Copy link
Copy Markdown
Contributor Author

Addressed — the scope is now correct and every module clears 80% on its own tests:

module line coverage
core 95%
codegen-core 90%
codegen-roaster 91%
codegen-testing 91%
simple-processor 84%
processor 97%

Scope fixes: **/codegen/model/**, **/processor/model/**, **/enums/**, **/*Exception.*, **/exceptions/** and **/JavadocConstants.* are excluded from the JaCoCo report, configured identically in all six subprojects; the enum-only test class was removed. Also fixed: the core module never ran its tests (missing surefire pin → JUnit 5 silently skipped); it now runs 87 tests at 95%.

@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Comment thread codegen-roaster/pom.xml Resolved
@AndreasIgel

Copy link
Copy Markdown
Collaborator

Why mentioning simple-builder or processor in javadoc outside the simple builder project?

@AndreasIgel

This comment has been minimized.

- CodegenTestUtils.probe(...) wraps ProbeProcessor + compile (JavaFileObject/String/List sources)
- ProcessingTestUtils.context shared across simple-processor tests
- TestingGenerationEnvironment.create() default capturing logger
- CapturingLogHandler promoted to codegen-testing util
- TypeName.toString() returns qualified name; TypeNameGeneric varargs via Arrays.stream
- ElementTestUtils method-ref parameter matching
- static helpers moved to end of test classes; per-test compile/context helpers removed
@AndreasIgel

This comment has been minimized.

- ProcessingTestUtils moved to codegen.testing package and gained a
  probe() overload asserting compilation success; all simple-processor
  test classes reuse it instead of their own probe+assert pattern
- generatesClassMetadataJavadocAndAnnotations now pins the full
  generated source textblock
- simplified TypeName/TypeNameGeneric constructions to the Class-based
  factory/ctor where applicable
- neutral 'codegen' logger prefix in codegen-core tests
- sonar: rename LogRecord param (restricted identifier), document empty
  flush(), extract duplicated literal to constant
@igel-devin-ai

This comment has been minimized.

@igel-devin-ai

This comment has been minimized.

@sonarqubecloud

Copy link
Copy Markdown

@AndreasIgel
AndreasIgel merged commit 9894d21 into java-helpers:main Nov 16, 2026
6 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the devin/1794429896-issue-390-module-tests branch November 22, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Each module should be covered by its own tests

3 participants