CircleCI error parsing test results


#1

I have a build.gradle running on CircleCI with the following characteristics:

  1. It contains the dependency: testCompile ‘junit:junit:4.12’
  2. It contains normal JUnit test cases.
  3. Tests run with commands like gradle build or gradle test
  4. When tests run, JUnit writes their results as XML files in the build/test-results directory. These are files with names like TEST-*.xml

However, CircleCI seems to be unable to parse these files. All it shows is a message like ‘The following errors were encountered parsing test results:’, and, then, a list of all the XML files.

Does anyone know whether it is necessary to generate these test results in a particular format? If so, what would it be?


#2

I’m having the same problem, did you already fix it?


#3

I added the Gradle Wrapper to my project, and the problem disappeared. I think it’s impossible to know which version of Gradle CircleCI is using unless you specify it with the Gradle Wrapper, and, apparently, this makes a difference. In addition, if you decide to add the Gradle Wrapper to your project, you must be careful and make sure that you commit both the “gradlew” executable file and the “gradle” directory to your code repository.


#4

Thanks a lot, this worked for me!

Just in case somebody is wondering how to do the whole thing, here is the circle.yml full config for tests :slight_smile:

test:
    override:
        - ./gradlew test
    post:
        - mkdir -p $CIRCLE_TEST_REPORTS/junit/
        - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;

#5