Skip to content

feat: support multiple test source sets (e.g. Gradle integrationTest suite) #48

@jimisola

Description

@jimisola

Problem

The plugin assumes a single test source set, which matches Maven's model. In Gradle projects that use multiple test source sets (e.g. a separate integrationTest JvmTestSuite), the annotation processor runs once per compilation task and produces one annotations.yml per source set:

Compilation task Annotation output
compileJava build/generated/sources/annotationProcessor/java/main/resources/annotations.yml
compileTestJava build/generated/sources/annotationProcessor/java/test/resources/annotations.yml
compileIntegrationTestJava build/generated/sources/annotationProcessor/java/integrationTest/resources/annotations.yml

RequirementsToolExtension only exposes a single svcsAnnotationsFile (RegularFileProperty), hardcoded by default to the test source set output. The integrationTest annotations are silently ignored.

Impact: @SVCs annotations placed on integration test methods are never picked up by reqstool status, resulting in artificially low SVC coverage even when tests exist.

Root cause

RequirementsToolExtension.java (line 49):

this.svcsAnnotationsFile.convention(project.getLayout()
    .getBuildDirectory()
    .file("generated/sources/annotationProcessor/java/test/resources/annotations.yml"));

RequirementsToolTask.execute() reads a single file:

File svcsAnnotFile = svcsAnnotationsFile.getAsFile().getOrNull();
if (svcsAnnotFile != null && svcsAnnotFile.exists()) {
    testsNode = yamlMapper.readTree(svcsAnnotFile).path(XML_REQUIREMENT_ANNOTATIONS).path(XML_TESTS);
}

Proposed fix

  1. Change svcsAnnotationsFile (RegularFileProperty) → svcsAnnotationsFiles (ConfigurableFileCollection) in both RequirementsToolExtension and RequirementsToolTask
  2. Default the collection to all known test-scope annotation outputs (auto-discover JvmTestSuite source sets, or at minimum include test + any additional suites)
  3. In RequirementsToolTask.execute(), merge all tests nodes from all provided files (deep-merge by SVC ID, concatenating the entry lists)

Backwards compatible: a single-file config still works; multi-suite projects get correct coverage without workarounds.

Workaround

Currently requires a custom Gradle task to merge the two annotation files before passing the result to svcsAnnotationsFile — an unnecessary build-script burden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions