Home > Mobile >  Unable to run spring boot tests using maven: No tests were executed
Unable to run spring boot tests using maven: No tests were executed

Time:07-06

I am unable to run tests for a spring boot app using maven. I have seen multiple posts about this, most of their solutions are to:

  • align a junit version with maven-surefire-plugin or
  • ensure a junit version is not predefined by a parent element

My project does not use a parent nor maven-surefire-plugin. Otherwise, based on the pom file, I don't see any glaring conflicts. I do see the junit:jar:4.13.2, but that is part of the junit-vintage dependency for backwards compatability.

What could be causing this?

Spring-Boot:  (v2.4.3)
Camunda Platform: (v7.15.0)
Camunda Platform Spring Boot Starter: (v7.15.0)

Apache Maven 3.6.3 
Java version: 11.0.8, vendor: Azul Systems, Inc., runtime: C:\Program Files (x86)\Zulu\zulu-11
OS name: "windows 10", version: "10.0", arch: "x86", family: "windows"

pom

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myapp</groupId>
  <artifactId>myappdemo</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.4.3</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-bom</artifactId>
        <version>7.15.0</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-plugin-spin</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.spin</groupId>
      <artifactId>camunda-spin-dataformat-all</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.oracle.database.jdbc</groupId>
      <artifactId>ojdbc11</artifactId>
      <version>21.4.0.0.1</version>
    </dependency>
    <dependency>
      <groupId>com.oracle.database.jdbc</groupId>
      <artifactId>ucp11</artifactId>
      <version>21.4.0.0.1</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>5.6.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>3.2.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.pdfbox</groupId>
      <artifactId>pdfbox</artifactId>
      <version>2.0.24</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.4.3</version>
        <configuration>
          <layout>ZIP</layout>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

mvn dependency:tree

[INFO]  - org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter:jar:7.15.0:compile
[INFO] |   - org.camunda.bpm:camunda-engine-spring:jar:7.15.0:compile
[INFO] |  |   - org.camunda.bpm:camunda-engine:jar:7.15.0:compile
[INFO] |  |  |   - org.camunda.bpm.model:camunda-bpmn-model:jar:7.15.0:compile
[INFO] |  |  |  |  \- org.camunda.bpm.model:camunda-xml-model:jar:7.15.0:compile
[INFO] |  |  |   - org.camunda.bpm.model:camunda-cmmn-model:jar:7.15.0:compile
[INFO] |  |  |   - org.camunda.bpm.dmn:camunda-engine-dmn:jar:7.15.0:compile
[INFO] |  |  |  |   - org.camunda.bpm.model:camunda-dmn-model:jar:7.15.0:compile
[INFO] |  |  |  |   - org.camunda.bpm.dmn:camunda-engine-feel-api:jar:7.15.0:compile
[INFO] |  |  |  |   - org.camunda.bpm.dmn:camunda-engine-feel-juel:jar:7.15.0:compile
[INFO] |  |  |  |   - org.camunda.bpm.dmn:camunda-engine-feel-scala:jar:7.15.0:compile
[INFO] |  |  |  |  \- org.camunda.feel:feel-engine:jar:scala-shaded:1.13.1:compile
[INFO] |  |  |   - org.camunda.commons:camunda-commons-typed-values:jar:7.15.0:compile
[INFO] |  |  |   - org.mybatis:mybatis:jar:3.5.6:compile
[INFO] |  |  |   - joda-time:joda-time:jar:2.1:compile
[INFO] |  |  |   - org.camunda.connect:camunda-connect-core:jar:1.5.2:compile
[INFO] |  |  |  \- org.camunda.connect:camunda-connect-connectors-all:jar:1.5.2:runtime
[INFO] |  |  \- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  |     \- commons-pool:commons-pool:jar:1.6:compile
[INFO] |   - org.springframework:spring-context:jar:5.3.4:compile
[INFO] |  |   - org.springframework:spring-beans:jar:5.3.4:compile
[INFO] |  |   - org.springframework:spring-core:jar:5.3.4:compile
[INFO] |  |  |  \- org.springframework:spring-jcl:jar:5.3.4:compile
[INFO] |  |  \- org.springframework:spring-expression:jar:5.3.4:compile
[INFO] |   - org.springframework:spring-jdbc:jar:5.3.4:compile
[INFO] |   - org.springframework:spring-tx:jar:5.3.4:compile
[INFO] |   - org.springframework:spring-orm:jar:5.3.4:compile
[INFO] |   - org.springframework.boot:spring-boot-loader-tools:jar:2.4.3:compile
[INFO] |  |  \- org.apache.commons:commons-compress:jar:1.20:compile
[INFO] |   - org.springframework.boot:spring-boot-autoconfigure:jar:2.4.3:compile
[INFO] |  |  \- org.springframework.boot:spring-boot:jar:2.4.3:compile
[INFO] |   - org.springframework.boot:spring-boot-starter:jar:2.4.3:compile
[INFO] |  |   - org.springframework.boot:spring-boot-starter-logging:jar:2.4.3:compile
[INFO] |  |  |   - ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |   - org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.3:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] |  |   - jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.27:compile
[INFO] |   - org.apache.commons:commons-lang3:jar:3.11:compile
[INFO] |  \- com.fasterxml.uuid:java-uuid-generator:jar:3.2.0:compile
[INFO]  - org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-rest:jar:7.15.0:compile
[INFO] |   - org.camunda.bpm:camunda-engine-rest-jaxrs2:jar:7.15.0:compile
[INFO] |  |   - commons-fileupload:commons-fileupload:jar:1.4:compile
[INFO] |  |   - commons-io:commons-io:jar:2.8.0:compile
[INFO] |  |   - com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.11.4:compile
[INFO] |  |   - com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.11.4:compile
[INFO] |  |   - com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.11.4:compile
[INFO] |  |   - com.fasterxml.jackson.core:jackson-databind:jar:2.11.4:compile
[INFO] |  |   - com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.11.4:compile
[INFO] |  \- org.springframework.boot:spring-boot-starter-jersey:jar:2.4.3:compile
[INFO] |      - org.springframework.boot:spring-boot-starter-validation:jar:2.4.3:compile
[INFO] |     |  \- org.hibernate.validator:hibernate-validator:jar:6.1.7.Final:compile
[INFO] |      - org.glassfish.jersey.core:jersey-server:jar:2.32:compile
[INFO] |     |   - org.glassfish.jersey.core:jersey-common:jar:2.32:compile
[INFO] |     |  |  \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.3:compile
[INFO] |     |   - org.glassfish.jersey.core:jersey-client:jar:2.32:compile
[INFO] |     |   - jakarta.ws.rs:jakarta.ws.rs-api:jar:2.1.6:compile
[INFO] |     |   - org.glassfish.jersey.media:jersey-media-jaxb:jar:2.32:compile
[INFO] |     |   - org.glassfish.hk2.external:jakarta.inject:jar:2.6.1:compile
[INFO] |     |  \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] |      - org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.32:compile
[INFO] |      - org.glassfish.jersey.containers:jersey-container-servlet:jar:2.32:compile
[INFO] |      - org.glassfish.jersey.ext:jersey-bean-validation:jar:2.32:compile
[INFO] |      - org.glassfish.jersey.ext:jersey-spring5:jar:2.32:compile
[INFO] |     |   - org.glassfish.jersey.inject:jersey-hk2:jar:2.32:compile
[INFO] |     |  |  \- org.glassfish.hk2:hk2-locator:jar:2.6.1:compile
[INFO] |     |  |     \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.6.1:compile
[INFO] |     |   - org.glassfish.hk2:hk2:jar:2.6.1:compile
[INFO] |     |  |   - org.glassfish.hk2:hk2-utils:jar:2.6.1:compile
[INFO] |     |  |   - org.glassfish.hk2:hk2-api:jar:2.6.1:compile
[INFO] |     |  |   - org.glassfish.hk2:hk2-core:jar:2.6.1:compile
[INFO] |     |  |   - org.glassfish.hk2:hk2-runlevel:jar:2.6.1:compile
[INFO] |     |  |  \- org.glassfish.hk2:class-model:jar:2.6.1:compile
[INFO] |     |  |      - org.ow2.asm:asm:jar:7.1:compile
[INFO] |     |  |      - org.ow2.asm:asm-analysis:jar:7.1:compile
[INFO] |     |  |      - org.ow2.asm:asm-commons:jar:7.1:compile
[INFO] |     |  |      - org.ow2.asm:asm-tree:jar:7.1:compile
[INFO] |     |  |     \- org.ow2.asm:asm-util:jar:7.1:compile
[INFO] |     |  \- org.glassfish.hk2:spring-bridge:jar:2.6.1:compile
[INFO] |     \- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.32:compile
[INFO] |        \- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.32:compile
[INFO]  - org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:jar:7.15.0:compile
[INFO] |   - org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp-core:jar:7.15.0:compile
[INFO] |  |  \- org.camunda.bpm.webapp:camunda-webapp:jar:classes:7.15.0:compile
[INFO] |  \- org.camunda.bpm.webapp:camunda-webapp-webjar:jar:7.15.0:compile
[INFO]  - org.camunda.bpm:camunda-engine-plugin-spin:jar:7.15.0:compile
[INFO] |  \- org.camunda.spin:camunda-spin-core:jar:1.10.1:compile
[INFO]  - org.camunda.spin:camunda-spin-dataformat-all:jar:1.10.1:compile
[INFO] |   - org.camunda.commons:camunda-commons-logging:jar:1.10.0:compile
[INFO] |   - org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] |  \- org.camunda.commons:camunda-commons-utils:jar:1.10.0:compile
[INFO]  - org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-test:jar:7.15.0:compile
[INFO] |   - org.springframework.boot:spring-boot-starter-test:jar:2.4.3:compile
[INFO] |  |   - org.springframework.boot:spring-boot-test:jar:2.4.3:compile
[INFO] |  |   - org.springframework.boot:spring-boot-test-autoconfigure:jar:2.4.3:compile
[INFO] |  |   - com.jayway.jsonpath:json-path:jar:2.4.0:compile
[INFO] |  |  |  \- net.minidev:json-smart:jar:2.3:compile
[INFO] |  |  |     \- net.minidev:accessors-smart:jar:1.2:compile
[INFO] |  |   - jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] |  |  |  \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] |  |   - org.assertj:assertj-core:jar:3.18.1:compile
[INFO] |  |   - org.hamcrest:hamcrest:jar:2.2:compile
[INFO] |  |   - org.skyscreamer:jsonassert:jar:1.5.0:compile
[INFO] |  |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:compile
[INFO] |  |   - org.springframework:spring-test:jar:5.3.4:compile
[INFO] |  |  \- org.xmlunit:xmlunit-core:jar:2.7.0:compile
[INFO] |   - org.junit.vintage:junit-vintage-engine:jar:5.7.1:compile
[INFO] |  |   - org.apiguardian:apiguardian-api:jar:1.1.0:compile
[INFO] |  |   - org.junit.platform:junit-platform-engine:jar:1.7.1:compile
[INFO] |  |  \- junit:junit:jar:4.13.2:compile
[INFO] |  \- org.camunda.bpm.assert:camunda-bpm-assert-assertj3-11-1:jar:4.0.0:compile
[INFO]  - org.springframework.boot:spring-boot-starter-security:jar:2.4.3:compile
[INFO] |   - org.springframework:spring-aop:jar:5.3.4:compile
[INFO] |   - org.springframework.security:spring-security-config:jar:5.4.5:compile
[INFO] |  |  \- org.springframework.security:spring-security-core:jar:5.4.5:compile
[INFO] |  \- org.springframework.security:spring-security-web:jar:5.4.5:compile
[INFO]  - org.springframework.boot:spring-boot-starter-web:jar:2.4.3:compile
[INFO] |   - org.springframework.boot:spring-boot-starter-json:jar:2.4.3:compile
[INFO] |  |   - com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.4:compile
[INFO] |  |   - com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4:compile
[INFO] |   - org.springframework.boot:spring-boot-starter-tomcat:jar:2.4.3:compile
[INFO] |  |   - org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.43:compile
[INFO] |  |   - org.glassfish:jakarta.el:jar:3.0.3:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.43:compile
[INFO] |   - org.springframework:spring-web:jar:5.3.4:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.3.4:compile
[INFO]  - mysql:mysql-connector-java:jar:8.0.23:runtime
[INFO]  - com.h2database:h2:jar:1.4.200:compile
[INFO]  - com.oracle.database.jdbc:ojdbc11:jar:21.4.0.0.1:compile
[INFO]  - com.oracle.database.jdbc:ucp11:jar:21.4.0.0.1:compile
[INFO]  - org.springframework.boot:spring-boot-starter-jdbc:jar:2.4.3:compile
[INFO] |  \- com.zaxxer:HikariCP:jar:3.4.5:compile
[INFO]  - org.springframework.boot:spring-boot-starter-data-jpa:jar:2.4.3:compile
[INFO] |   - org.springframework.boot:spring-boot-starter-aop:jar:2.4.3:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.9.6:compile
[INFO] |   - jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
[INFO] |   - jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile
[INFO] |   - org.hibernate:hibernate-core:jar:5.4.28.Final:compile
[INFO] |  |   - org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile
[INFO] |  |   - org.javassist:javassist:jar:3.27.0-GA:compile
[INFO] |  |   - net.bytebuddy:byte-buddy:jar:1.10.20:compile
[INFO] |  |   - antlr:antlr:jar:2.7.7:compile
[INFO] |  |   - org.jboss:jandex:jar:2.2.3.Final:compile
[INFO] |  |   - com.fasterxml:classmate:jar:1.5.1:compile
[INFO] |  |   - org.dom4j:dom4j:jar:2.1.3:compile
[INFO] |  |   - org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile
[INFO] |  |  \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.3:compile
[INFO] |  |      - org.glassfish.jaxb:txw2:jar:2.3.3:compile
[INFO] |  |     \- com.sun.istack:istack-commons-runtime:jar:3.0.11:compile
[INFO] |   - org.springframework.data:spring-data-jpa:jar:2.4.5:compile
[INFO] |  |  \- org.springframework.data:spring-data-commons:jar:2.4.5:compile
[INFO] |  \- org.springframework:spring-aspects:jar:5.3.4:compile
[INFO]  - org.springframework.boot:spring-boot-starter-mail:jar:2.4.3:compile
[INFO] |   - org.springframework:spring-context-support:jar:5.3.4:compile
[INFO] |  \- com.sun.mail:jakarta.mail:jar:1.6.5:compile
[INFO] |     \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO]  - org.junit.jupiter:junit-jupiter:jar:5.6.0:test
[INFO] |   - org.junit.jupiter:junit-jupiter-api:jar:5.7.1:test
[INFO] |  |   - org.opentest4j:opentest4j:jar:1.2.0:compile
[INFO] |  |  \- org.junit.platform:junit-platform-commons:jar:1.7.1:compile
[INFO] |   - org.junit.jupiter:junit-jupiter-params:jar:5.7.1:test
[INFO] |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.7.1:test
[INFO]  - org.mockito:mockito-junit-jupiter:jar:3.2.4:test
[INFO] |  \- org.mockito:mockito-core:jar:3.6.28:compile
[INFO] |      - net.bytebuddy:byte-buddy-agent:jar:1.10.20:compile
[INFO] |     \- org.objenesis:objenesis:jar:3.1:compile
[INFO] \- org.apache.pdfbox:pdfbox:jar:2.0.24:compile
[INFO]     - org.apache.pdfbox:fontbox:jar:2.0.24:compile
[INFO]    \- commons-logging:commons-logging:jar:1.2:compile
[INFO] ------------------------------------------------------------------------

CodePudding user response:

My project does not use a parent nor maven-surefire-plugin

How are you going to run junit test without maven-surefire-plugin? :)

Actually, maven has a concept of default bindings when for particular packaging it predefines plugins and versions. In case of Apache Maven 3.6.3 the default version of maven-surefire-plugin is 2.12, basic support of junit-jupiter was introduced in 2.22 - you either need to setup maven-surefire-plugin or switch to recent version of maven.

CodePudding user response:

First upgrade your Spring Boot version (because a bit out of date or more accurate out of support) and second upgrade your Maven version (also out dated) ...also define the junit-bom to define the correct junit jupiter version like this:

  <dependency>
    <groupId>org.junit</groupId>
    <artifactId>junit-bom</artifactId>
    <version>5.8.2</version>
    <scope>import</scope>
    <type>pom</type>
  </dependency>

This has to be done before the import of the spring boot dependencies to overwrite correctly the version which is provided by spring-boot-dependencies.

Also you are not using spring boot as a parent which means you have to define all needed maven plugins. Based on that you are using the default bindings which are defined via the packaging binding.

I strongly recommend to define all needed plugins in your plugin with the appropriate versions which makes it sure to use defined versions of plugins which will never change in the future. This makes your build repeatable.

The first versions which correctly support JUnit Jupiter is maven-surefire-plugin (2.22.2) ... I strongly recommend to use the most recent version.

More details explained in two videos one and the second one

  • Related