Test reports for Gitlab CI when multiple modules exist



  • I am trying to setup build scripts for Gitlab CI for a Java/ project with Gradle. The project has three different modules A, B and C, with modules B and C being dependent on the module A.

    All three have a build.gradle file and unit tests inside them. There is also a build.gradle file in the root of the project. I am trying to have test reports available in GitLab CI when a new push is made. I managed to have the test executed with ease by executing the check gradle command with a script similar to this one:

    test:
      stage: test
      script:
        - ./gradlew check
    

    THis, however, does not provide any test reports. In the logs I only see something like this:

    Starting a Gradle Daemon (subsequent builds will be faster)
    > Task :compileJava NO-SOURCE
    > Task :processResources NO-SOURCE
    > Task :classes UP-TO-DATE
    > Task :compileTestJava NO-SOURCE
    > Task :processTestResources NO-SOURCE
    > Task :testClasses UP-TO-DATE
    > Task :test NO-SOURCE
    > Task :check UP-TO-DATE
    > Task :A:compileJava
    > Task :A:processResources NO-SOURCE
    > Task :A:classes
    > Task :A:jar
    > Task :B:compileJava
    > Task :B:processResources NO-SOURCE
    > Task :B2:classes
    > Task :B:compileTestJava
    > Task :B:processTestResources
    > Task :B:testClasses
    > Task :B:test
    > Task :B:check
    > Task :A:compileTestJava
    > Task :Ar:processTestResources NO-SOURCE
    > Task :A:testClasses
    > Task :A:test
    > Task :A:check
    BUILD SUCCESSFUL in 42s
    

    It is good that the build fails if the test fails, but I don't have any indication to what tests were executed, what tests failed or any other information.

    Can anyone help with some resources or hints on how to solve this.



  • The Ci.CD pipeline allows having a list of artifacts:

    test:
      stage: test
      script:
        - ./gradlew test
      artifacts:
        when: always
        reports:
          junit: 
            - a/build/test-results/test/**/TEST-*.xml
            - b/build/test-results/test/**/TEST-*.xml
            - c/build/test-results/test/**/TEST-*.xml
    



Suggested Topics