Repository navigation
test: split processor tests into the modules they cover - #401
AndreasIgel merged 13 commits into
Conversation
…#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%).
This comment has been minimized.
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>
|
Addressed — the scope is now correct and every module clears 80% on its own tests:
Scope fixes: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…778, richer Roaster test asserts
…sue-390-module-tests
…sAnnotatedWith, JUL logging capture
|
Why mentioning simple-builder or processor in javadoc outside the simple builder project? |
This comment has been minimized.
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
This comment has been minimized.
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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|



Closes #390.
Each extracted codegen module now proves its behavior with tests in its own module, without simple-builder types.
Test moves
JavaLangAnalyserTest(26)processorsimple-processorOptionValueParsersTest(7)processorsimple-processorProcessorOptionRegistryTest(2)processorsimple-processorCodegenProcessorConfigurationTest(1)processorsimple-processorElementCollectorTest(1)processorsimple-processorMinimalCodegenProcessorTest(1)processorsimple-processor— exercisesAbstractCodegenProcessorend-to-end without builder typesActivePerformanceTrackerTest(25)processorcodegen-core— uses a local capturing logger, sincecodegen-testingwould be a dependency cycleFormatterProfileTestUtilsTest(2)processorcodegen-testing— a minimaleclipse-java-format.xmltest resource stands in for the bundled codegen-roaster profileRoasterCodeGeneratorResilienceTest(2)processorcodegen-roaster— environment rebuilt fromcodegen-core/codegen-testingtypesNew tests
simple-processor:JavaLangMapperTestandFieldAnnotationExtractorTest, driven by a probe processor capturing liveTypeElement/VariableElements from a real compilation.codegen-roaster:RoasterCodeGeneratorTestpasses genericGenerationTargetClassDtos 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
processorno longer depends oncodegen-roaster— the only main-code mention was a javadoc reference inBuilderDefinitionCreator, now kept as plain text.codegen-roasterarrives transitively throughsimple-processor.Coverage, measured per module on its own (
mvn clean install -Pmetrics)codegen-coresimple-processorcodegen-roastercodegen-testingprocessorThe 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.