Collect test result when tests fail


#1

I’m running a Java project. I have the following structure:

  • main_project
    • pom.xml
    • project_a
      • pom.xml
    • project_b
      • pom.xml
    • project_c
      • pom.xml

I run the following command on the main_project folder:

mvn -DskipTests=false -DskipBugSearch=false clean install

This will execute all the tests, including the ones from project_a, project_b and project_c.

After that I execute the following command:

sudo find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} /tmp/test-results \;

The goal of this command is to copy all xml results from all projects and place it into the /tmp/test-results folder.

The next step is to store the results (which is pretty straighforward):

- store_test_results:
    path: /tmp/test-results

This flow work fine. I got the results in the end as as expected and they are displayed on the build.

The problem happens when some test fail: the copy command will not execute and there is no xml file on the /tmp/test-results folder, so no test results are displayed…

What do I need:

  1. Allow me to execute a command when one step fail or;
  2. Allow me to pass a regex to the path field on store_test_results.

Please notice that I need the build to fail. I got the tests results to be displayed using the set +e command but CircleCI makes the build pass, which is an undesired behavior.

Any ideas on how to solve this?


#2

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.