[CircleCI 2.0] [Java] [Maven] [JUnit] Aggregate JUnit test results with CircleCI 2.0

I tried using CircleCI 2.0 for Java automatic test execution, but the official document method resulted in permission denied at mkdir, so make a note of the corresponding procedure. (Maybe I made a mistake in the document or lacked information ...)

Collecting Test Metadata - CircleCI

Official documentation method


    steps:
      - run: |
          mkdir -p /junit/
          find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} /junit/ \;
      - store_test_results:
          path: /junit
      - store_artifacts:
          path: /junit   

How to fix(Created under a directory in the workspace, not from the root directory)


       - run: |
          mkdir -p ~/repo/junit/
          find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/repo/junit/ \;

       - store_test_results:
          path: ~/repo/junit

       - store_artifacts:
          path: ~/repo/junit 

When 1.0 has $ CIRCLE_TEST_REPORTS and specify that I was doing it, but it seems that this environment variable has been deleted when it is 2.0.

.Circleci / config.yml for Java 8 environment

Since it is only the aggregated part of the test, I will also post the full text of the settings verified this time. (I just added a test aggregation task for Maven to the sample)

# Java Maven CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
 version: 2
 jobs:
   build:
     docker:
       # specify the version you desire here
       - image: circleci/openjdk:8-jdk

       # Specify service dependencies here if necessary
       # CircleCI maintains a library of pre-built images
       # documented at https://circleci.com/docs/2.0/circleci-images/
       # - image: circleci/postgres:9.4

     working_directory: ~/repo

     environment:
       # Customize the JVM maximum heap limit
       MAVEN_OPTS: -Xmx3200m

     steps:
       - checkout

       # Download and cache dependencies
       - restore_cache:
           keys:
           - v1-dependencies-{{ checksum "pom.xml" }}
           # fallback to using the latest cache if no exact match is found
           - v1-dependencies-

       - run: mvn dependency:go-offline

       - save_cache:
           paths:
             - ~/.m2
           key: v1-dependencies-{{ checksum "pom.xml" }}

       # run tests!
       - run: mvn integration-test

       - run: |
          mkdir -p ~/repo/junit/
          find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/repo/junit/ \;

       - store_test_results:
          path: ~/repo/junit

       - store_artifacts:
          path: ~/repo/junit

Recommended Posts

[CircleCI 2.0] [Java] [Maven] [JUnit] Aggregate JUnit test results with CircleCI 2.0
Java automated test implementation with JUnit 5 + Apache Maven
[Java] Test private methods with JUnit
Java automated test implementation with JUnit 5 + Gradle
Automate Java (Maven) project build with CircleCI + Orbs
Unit test with Junit.
Compile with Java 6 and test with Java 11 while running Maven on Java 8
[Java] JUnit4 test case example
Test Web API with junit
Try gRPC with Java, Maven
[Java] I want to test standard input & standard output with JUnit
Output JUnit test report in Maven
Test Spring framework controller with Junit
Control test order in Junit4 with enumeration
Java EE test (CDI / interceptor) with Arquillian
CICS-Run Java applications-(2) Build management with Maven
How to test private scope with JUnit
JUnit 5 gradle test fails with lombok annotation
How to test interrupts during Thread.sleep with JUnit
Deploy Java web app to Azure with maven
Build and test Java + Gradle applications with Wercker
Easy JUnit test of Elasticsearch 2018 version with embedded-elasticsearch
Build an E2E test environment with Selenium (Java)
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Test code using mock with JUnit (EasyMock center)
Java Repository of Eclipse with Maven: Missing artifact ~
Mixin test cases with JUnit 5 and default methods
Primality test Java
java, maven memo
Test the contents of an Excel file with JUnit
[JUnit 5 compatible] Write a test using JUnit 5 with Spring boot 2.2, 2.3
Use aggregate queries (Count) with Azure CosmosDB Java SDK
[JUnit 5] Write a validation test with Spring Boot! [Parameterization test]
WebAPI unit test and integration test with SpringBoot + Junit5, 4 patterns
I wrote a test with Spring Boot + JUnit 5 now