Skip to content

Each module should be covered by its own tests #390

Closed

Description

@igel-devin-ai

Part of #233.

Problem

The codegen modules extracted in #368 are meant to be reusable by other code generators. Today they are tested almost only through the tests of simple-builder (processor); their own tests cover little or nothing.

Module Own tests Line coverage from own tests Line coverage including the simple-builder tests
codegen-core 18 0% 96%
simple-processor 1 0% 92%
codegen-roaster 32 31% 92%
codegen-testing 0 no report not measured
core 87 81% –
processor (simple-builder) 485 98% –

Measured on main with mvn clean install -Pmetrics: the JaCoCo report of each module against the aggregate report of processor. The 18 tests of codegen-core cover only model classes, which are excluded from coverage.

The gap is not visible in SonarCloud and Codecov, because both read the aggregate report, where the generic modules count as covered by the simple-builder tests.

Goal

codegen-core, simple-processor, codegen-roaster and codegen-testing each prove their behavior with tests in their own module, without simple-builder types, and their coverage is measured from these tests alone.

Tasks

  • Move the tests that already test a generic class. These tests sit in processor but do not need the builder domain:

    Test (in processor) Tests Belongs to
    JavaLangAnalyserTest 22 simple-processor
    OptionValueParsersTest 7 simple-processor
    ProcessorOptionRegistryTest 2 simple-processor
    CodegenProcessorConfigurationTest 1 simple-processor
    ElementCollectorTest 1 simple-processor
    ActivePerformanceTrackerTest 25 codegen-core
    FormatterProfileTestUtilsTest 2 codegen-testing
  • Write the missing tests.

    • simple-processor: AbstractCodegenProcessor, JavaLangMapper and FieldAnnotationExtractor, driven by a minimal test processor (as in MinimalCodegenProcessorTest) instead of BuilderProcessor.
    • codegen-roaster: RoasterCodeGenerator is tested only from processor (RoasterCodeGeneratorEdgeCasesTest through generated builders, RoasterCodeGeneratorResilienceTest with generic DTOs, see the next task). It needs tests in its own module that pass generic DTOs to it directly.
    • codegen-core: logging, util and enums.
    • codegen-testing: the helper classes themselves.
  • Move RoasterCodeGeneratorResilienceTest to codegen-roaster and drop the direct dependency. It is the only class in processor that uses codegen-roaster types (RoasterCodeGenerator, RoasterSourceFormatter, RoasterMapperException); the main code names the module in one javadoc only. The test already passes generic DTOs to the generator, but builds its environment from BuilderProcessingContext, AnnotationProcessingEnvironment and MessagerProcessingLogger. In codegen-roaster it needs a GenerationEnvironment built from codegen-core and codegen-testing types, because codegen-roaster cannot depend on simple-processor. After the move, remove the codegen-roaster dependency from processor/pom.xml: it then arrives transitively through simple-processor, as Checking dependencies after separation - Roaster should become a transitive dependency #374 asks for Roaster itself (follow-up of build: depend on Roaster only in codegen-roaster (#374) #394).

  • Measure each module on its own. The coverage of a generic module comes from its own report, not from the aggregate of processor.

  • Agree on the target per module. Codecov requires 80% for the project and 90% for new code today.

Rules for the tests

  • codegen-core cannot use codegen-testing (dependency cycle), so its tests use plain JUnit.
  • Use the existing assertion helpers: ProcessorAsserts (codegen-testing) for generic tests, BuilderAsserts for simple-builder tests.
  • Check generated code with text blocks instead of single lines or small fragments. This finds real problems and keeps the expectation readable.

Activity

  1. changed the title [-]Each module should have good test coverage from its own tests[/-] [+]Each module should be covered by its own tests[/+] on Nov 10, 2026
  2. added this to the v0.7.0 milestone on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions