Surefire multi-module spring-boot 项目
Surefire on multi-module spring-boot project
所以我有一个简单的项目,例如:
foo.parent
- pom.xml
- /foo.service
- pom.xml
- /src
- /main
- /java/...
- /test
- /java/some/package/TestClass.java
- /foo.common
- pom.xml
- ...
- /foo.dataaccess
- pom.xml
- ...
而 foo.parent 的 pom.xml 看起来像:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath />
</parent>
<groupId>foooooo</groupId>
<artifactId>foo.parent</artifactId>
<packaging>pom</packaging>
<version>2.31.1-SNAPSHOT</version>
<modules>
<module>foo.common</module>
<module>foo.dataaccess</module>
<module>foo.service</module>
...
</modules>
<properties>
<jdk.version>1.8</jdk.version>
...
<maven-surefire-version>3.0.0-M3</maven-surefire-version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.dataaccess</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2020.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.1.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<tag>v${releaseVersion}</tag>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<pluginManagement>
<!-- PLUGIN MANAGEMENT IS THE THING INHERITING TO SUB MODULES -->
<plugins>
<plugin>
<!-- used to run tests -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-version}</version>
<configuration>
<argLine>
-Ddetail=true
</argLine>
<!-- if more than 10 tests failed skip the rest, fix them first -->
<skipAfterFailureCount>10</skipAfterFailureCount>
<!-- if a test failed run it again, just to be sure -->
<rerunFailingTestsCount>2</rerunFailingTestsCount>
<!-- reuse the same directory as sonar -->
<reportDirectory>${sonar.junit.reportPaths}</reportDirectory>
<!-- classes directory is target/test-classes-->
<useSystemClassLoader>false</useSystemClassLoader>
<!-- atleast one test -->
<failIfNoTests>true</failIfNoTests>
</configuration>
</plugin>
<plugin>
<!-- used to report test results -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-version}</version>
</plugin>
</plugins>
</reporting>
</project>
以及任何 child 的 pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>foooooo</groupId>
<artifactId>foo.parent</artifactId>
<version>2.31.1-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<artifactId>foo.dataaccess</artifactId>
<version>2.31.1-SNAPSHOT</version>
<name>foo.dataaccess</name>
<properties>
<java.version>1.8</java.version>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
<dependencies>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.common</artifactId>
</dependency>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
无论我做什么 maven-surefire 都不会执行任何测试,即使 testSourceDir buildOutputDirectory 等设置正确。我也没有修改任何特殊搜索词(所有测试都以 Test.java 结尾)。
如何让 surefire 打印比这更多的东西:
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ foo.dataaccess ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3, parent: sun.misc.Launcher$AppClassLoader@18b4aac2]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test' with basic configurator -->
[DEBUG] (s) additionalClasspathElements = []
[DEBUG] (s) argLine = -Ddetail=true
[DEBUG] (s) basedir = C:\WIN-PATH\foo\foo.parent\foo.dataaccess
[DEBUG] (s) childDelegation = false
[DEBUG] (s) classesDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\classes
[DEBUG] (s) classpathDependencyExcludes = []
[DEBUG] (s) dependenciesToScan = []
[DEBUG] (s) disableXmlReport = false
[DEBUG] (s) enableAssertions = true
[DEBUG] (s) encoding = UTF-8
[DEBUG] (s) failIfNoTests = true
[DEBUG] (f) forkCount = 1
[DEBUG] (s) forkMode = once
[DEBUG] (s) forkedProcessExitTimeoutInSeconds = 30
[DEBUG] (s) junitArtifactName = junit:junit
[DEBUG] (s) junitPlatformArtifactName = org.junit.platform:junit-platform-engine
[DEBUG] (s) localRepository = id: local
url: file:///C:/Develop/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]
[DEBUG] (f) parallelMavenExecution = false
[DEBUG] (s) parallelOptimized = true
[DEBUG] (s) perCoreThreadCount = true
[DEBUG] (s) pluginArtifactMap = {org.apache.maven.plugins:maven-surefire-plugin=org.apache.maven.plugins:maven-surefire-plugin:maven-plugin:3.0.0-M3:, org.apache.maven.surefire:maven-surefire-common=org.apache.maven.surefire:maven-surefire-common:jar:3.0.0-M3:compile, org.apache.maven.surefire:surefire-api=org.apache.maven.surefire:surefire-api:jar:3.0.0-M3:compile, org.apache.maven.surefire:surefire-logger-api=org.apache.maven.surefire:surefire-logger-api:jar:3.0.0-M3:compile, org.apache.maven.surefire:surefire-booter=org.apache.maven.surefire:surefire-booter:jar:3.0.0-M3:compile, org.apache.maven:maven-toolchain=org.apache.maven:maven-toolchain:jar:3.0-alpha-2:compile, org.apache.maven:maven-core=org.apache.maven:maven-core:jar:3.0:compile, org.apache.maven:maven-model=org.apache.maven:maven-model:jar:3.0:compile, org.apache.maven:maven-settings=org.apache.maven:maven-settings:jar:3.0:compile, org.apache.maven:maven-settings-builder=org.apache.maven:maven-settings-builder:jar:3.0:compile, org.apache.maven:maven-repository-metadata=org.apache.maven:maven-repository-metadata:jar:3.0:compile, org.apache.maven:maven-artifact=org.apache.maven:maven-artifact:jar:3.0:compile, org.apache.maven:maven-plugin-api=org.apache.maven:maven-plugin-api:jar:3.0:compile, org.apache.maven:maven-model-builder=org.apache.maven:maven-model-builder:jar:3.0:compile, org.apache.maven:maven-aether-provider=org.apache.maven:maven-aether-provider:jar:3.0:runtime, org.sonatype.aether:aether-impl=org.sonatype.aether:aether-impl:jar:1.7:compile, org.sonatype.aether:aether-spi=org.sonatype.aether:aether-spi:jar:1.7:compile, org.sonatype.aether:aether-api=org.sonatype.aether:aether-api:jar:1.7:compile, org.sonatype.aether:aether-util=org.sonatype.aether:aether-util:jar:1.7:compile, org.sonatype.sisu:sisu-inject-plexus=org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile, org.sonatype.sisu:sisu-inject-bean=org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile, org.sonatype.sisu:sisu-guice=org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile, org.codehaus.plexus:plexus-interpolation=org.codehaus.plexus:plexus-interpolation:jar:1.14:compile, org.codehaus.plexus:plexus-utils=org.codehaus.plexus:plexus-utils:jar:2.0.4:compile, org.codehaus.plexus:plexus-classworlds=org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile, org.codehaus.plexus:plexus-component-annotations=org.codehaus.plexus:plexus-component-annotations:jar:1.7.1:compile, org.sonatype.plexus:plexus-sec-dispatcher=org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile, org.sonatype.plexus:plexus-cipher=org.sonatype.plexus:plexus-cipher:jar:1.4:compile, org.apache.maven:maven-compat=org.apache.maven:maven-compat:jar:3.0:compile, org.apache.maven.wagon:wagon-provider-api=org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile, org.codehaus.plexus:plexus-java=org.codehaus.plexus:plexus-java:jar:1.0.1:compile, org.ow2.asm:asm=org.ow2.asm:asm:jar:7.0-beta:compile, com.thoughtworks.qdox:qdox=com.thoughtworks.qdox:qdox:jar:2.0-M9:compile}
[DEBUG] (f) pluginDescriptor = Component Descriptor: role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugin.surefire.HelpMojo', role hint: 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:help'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugin.surefire.SurefirePlugin', role hint: 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test'
---
[DEBUG] (s) printSummary = true
[DEBUG] (s) project = MavenProject: some.package.foo:foo.dataaccess:2.31.1-SNAPSHOT @ C:\WIN-PATH\foo\foo.parent\foo.dataaccess\pom.xml
[DEBUG] (s) projectArtifactMap = {org.springframework.boot:spring-boot-starter-data-jpa=org.springframework.boot:spring-boot-starter-data-jpa:jar:2.4.4:compile, org.springframework.boot:spring-boot-starter-aop=org.springframework.boot:spring-boot-starter-aop:jar:2.4.4:compile, org.aspectj:aspectjweaver=org.aspectj:aspectjweaver:jar:1.9.6:compile, org.springframework.boot:spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc:jar:2.4.4:compile, com.zaxxer:HikariCP=com.zaxxer:HikariCP:jar:3.4.5:compile, org.springframework:spring-jdbc=org.springframework:spring-jdbc:jar:5.3.5:compile, jakarta.transaction:jakarta.transaction-api=jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile, jakarta.persistence:jakarta.persistence-api=jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile, org.hibernate:hibernate-core=org.hibernate:hibernate-core:jar:5.4.29.Final:compile, org.jboss.logging:jboss-logging=org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile, org.javassist:javassist=org.javassist:javassist:jar:3.27.0-GA:compile, net.bytebuddy:byte-buddy=net.bytebuddy:byte-buddy:jar:1.10.22:compile, antlr:antlr=antlr:antlr:jar:2.7.7:compile, org.jboss:jandex=org.jboss:jandex:jar:2.2.3.Final:compile, com.fasterxml:classmate=com.fasterxml:classmate:jar:1.5.1:compile, org.dom4j:dom4j=org.dom4j:dom4j:jar:2.1.3:compile, org.hibernate.common:hibernate-commons-annotations=org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile, org.glassfish.jaxb:jaxb-runtime=org.glassfish.jaxb:jaxb-runtime:jar:2.3.3:compile, org.glassfish.jaxb:txw2=org.glassfish.jaxb:txw2:jar:2.3.3:compile, com.sun.istack:istack-commons-runtime=com.sun.istack:istack-commons-runtime:jar:3.0.11:compile, com.sun.activation:jakarta.activation=com.sun.activation:jakarta.activation:jar:1.2.2:runtime, org.springframework.data:spring-data-jpa=org.springframework.data:spring-data-jpa:jar:2.4.6:compile, org.springframework.data:spring-data-commons=org.springframework.data:spring-data-commons:jar:2.4.6:compile, org.springframework:spring-orm=org.springframework:spring-orm:jar:5.3.5:compile, org.springframework:spring-context=org.springframework:spring-context:jar:5.3.5:compile, org.springframework:spring-tx=org.springframework:spring-tx:jar:5.3.5:compile, org.springframework:spring-beans=org.springframework:spring-beans:jar:5.3.5:compile, org.springframework:spring-aspects=org.springframework:spring-aspects:jar:5.3.5:compile, org.springframework.boot:spring-boot-starter-security=org.springframework.boot:spring-boot-starter-security:jar:2.4.4:compile, org.springframework.boot:spring-boot-starter=org.springframework.boot:spring-boot-starter:jar:2.4.4:compile, org.springframework.boot:spring-boot=org.springframework.boot:spring-boot:jar:2.4.4:compile, org.springframework.boot:spring-boot-autoconfigure=org.springframework.boot:spring-boot-autoconfigure:jar:2.4.4:compile, org.springframework.boot:spring-boot-starter-logging=org.springframework.boot:spring-boot-starter-logging:jar:2.4.4:compile, ch.qos.logback:logback-classic=ch.qos.logback:logback-classic:jar:1.2.3:compile, ch.qos.logback:logback-core=ch.qos.logback:logback-core:jar:1.2.3:compile, org.apache.logging.log4j:log4j-to-slf4j=org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.3:compile, org.apache.logging.log4j:log4j-api=org.apache.logging.log4j:log4j-api:jar:2.13.3:compile, org.slf4j:jul-to-slf4j=org.slf4j:jul-to-slf4j:jar:1.7.30:compile, jakarta.annotation:jakarta.annotation-api=jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile, org.yaml:snakeyaml=org.yaml:snakeyaml:jar:1.27:compile, org.springframework:spring-aop=org.springframework:spring-aop:jar:5.3.5:compile, org.springframework.security:spring-security-config=org.springframework.security:spring-security-config:jar:5.4.5:compile, org.springframework.security:spring-security-web=org.springframework.security:spring-security-web:jar:5.4.5:compile, org.springframework:spring-expression=org.springframework:spring-expression:jar:5.3.5:compile, org.springframework.boot:spring-boot-starter-test=org.springframework.boot:spring-boot-starter-test:jar:2.4.4:test, org.springframework.boot:spring-boot-test=org.springframework.boot:spring-boot-test:jar:2.4.4:test, org.springframework.boot:spring-boot-test-autoconfigure=org.springframework.boot:spring-boot-test-autoconfigure:jar:2.4.4:test, com.jayway.jsonpath:json-path=com.jayway.jsonpath:json-path:jar:2.4.0:test, net.minidev:json-smart=net.minidev:json-smart:jar:2.3:test, net.minidev:accessors-smart=net.minidev:accessors-smart:jar:1.2:test, org.ow2.asm:asm=org.ow2.asm:asm:jar:5.0.4:test, jakarta.xml.bind:jakarta.xml.bind-api=jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile, jakarta.activation:jakarta.activation-api=jakarta.activation:jakarta.activation-api:jar:1.2.2:compile, org.assertj:assertj-core=org.assertj:assertj-core:jar:3.18.1:test, org.hamcrest:hamcrest=org.hamcrest:hamcrest:jar:2.2:test, org.junit.jupiter:junit-jupiter=org.junit.jupiter:junit-jupiter:jar:5.7.1:test, org.junit.jupiter:junit-jupiter-api=org.junit.jupiter:junit-jupiter-api:jar:5.7.1:test, org.apiguardian:apiguardian-api=org.apiguardian:apiguardian-api:jar:1.1.0:test, org.opentest4j:opentest4j=org.opentest4j:opentest4j:jar:1.2.0:test, org.junit.platform:junit-platform-commons=org.junit.platform:junit-platform-commons:jar:1.7.1:test, org.junit.jupiter:junit-jupiter-params=org.junit.jupiter:junit-jupiter-params:jar:5.7.1:test, org.junit.jupiter:junit-jupiter-engine=org.junit.jupiter:junit-jupiter-engine:jar:5.7.1:test, org.junit.platform:junit-platform-engine=org.junit.platform:junit-platform-engine:jar:1.7.1:test, org.mockito:mockito-core=org.mockito:mockito-core:jar:3.6.28:test, net.bytebuddy:byte-buddy-agent=net.bytebuddy:byte-buddy-agent:jar:1.10.22:test, org.objenesis:objenesis=org.objenesis:objenesis:jar:3.1:test, org.mockito:mockito-junit-jupiter=org.mockito:mockito-junit-jupiter:jar:3.6.28:test, org.skyscreamer:jsonassert=org.skyscreamer:jsonassert:jar:1.5.0:test, com.vaadin.external.google:android-json=com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test, org.springframework:spring-core=org.springframework:spring-core:jar:5.3.5:compile, org.springframework:spring-jcl=org.springframework:spring-jcl:jar:5.3.5:compile, org.springframework:spring-test=org.springframework:spring-test:jar:5.3.5:test, org.xmlunit:xmlunit-core=org.xmlunit:xmlunit-core:jar:2.7.0:test, org.projectlombok:lombok=org.projectlombok:lombok:jar:1.18.18:compile, com.ibm.db2:db2jcc4=com.ibm.db2:db2jcc4:jar:4.25.13:compile, com.h2database:h2=com.h2database:h2:jar:1.4.200:compile, some.package.foo:foo.common=some.package.foo:foo.common:jar:2.31.1-SNAPSHOT:compile, org.springframework:spring-context-support=org.springframework:spring-context-support:jar:5.3.5:compile, org.springframework.security:spring-security-core=org.springframework.security:spring-security-core:jar:5.4.5:compile, junit:junit=junit:junit:jar:4.13.2:test, org.hamcrest:hamcrest-core=org.hamcrest:hamcrest-core:jar:2.2:test, org.apache.commons:commons-lang3=org.apache.commons:commons-lang3:jar:3.11:compile, org.apache.commons:commons-collections4=org.apache.commons:commons-collections4:jar:4.4:compile, com.auth0:java-jwt=com.auth0:java-jwt:jar:2.1.0:compile, net.sf.ehcache:ehcache=net.sf.ehcache:ehcache:jar:2.10.0:compile, org.slf4j:slf4j-api=org.slf4j:slf4j-api:jar:1.7.30:compile, net.bull.javamelody:javamelody-spring-boot-starter=net.bull.javamelody:javamelody-spring-boot-starter:jar:1.86.0:compile, net.bull.javamelody:javamelody-core=net.bull.javamelody:javamelody-core:jar:1.86.0:compile, org.jrobin:jrobin=org.jrobin:jrobin:jar:1.5.9:compile, commons-dbcp:commons-dbcp=commons-dbcp:commons-dbcp:jar:1.4:compile, commons-pool:commons-pool=commons-pool:commons-pool:jar:1.6:compile, org.databene:contiperf=org.databene:contiperf:jar:2.1.0:test, org.hsqldb:hsqldb=org.hsqldb:hsqldb:jar:2.3.3:compile, org.mapstruct:mapstruct=org.mapstruct:mapstruct:jar:1.4.1.Final:compile, org.liquibase:liquibase-core=org.liquibase:liquibase-core:jar:3.10.3:compile, javax.xml.bind:jaxb-api=javax.xml.bind:jaxb-api:jar:2.3.1:compile, javax.activation:javax.activation-api=javax.activation:javax.activation-api:jar:1.2.0:compile, org.springframework.cloud:spring-cloud-starter-config=org.springframework.cloud:spring-cloud-starter-config:jar:3.0.3:compile, org.springframework.cloud:spring-cloud-starter=org.springframework.cloud:spring-cloud-starter:jar:3.0.2:compile, org.springframework.cloud:spring-cloud-context=org.springframework.cloud:spring-cloud-context:jar:3.0.2:compile, org.springframework.security:spring-security-rsa=org.springframework.security:spring-security-rsa:jar:1.0.9.RELEASE:compile, org.bouncycastle:bcpkix-jdk15on=org.bouncycastle:bcpkix-jdk15on:jar:1.64:compile, org.bouncycastle:bcprov-jdk15on=org.bouncycastle:bcprov-jdk15on:jar:1.64:compile, org.springframework.cloud:spring-cloud-config-client=org.springframework.cloud:spring-cloud-config-client:jar:3.0.3:compile, com.fasterxml.jackson.core:jackson-annotations=com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile, org.apache.httpcomponents:httpclient=org.apache.httpcomponents:httpclient:jar:4.5.13:compile, org.apache.httpcomponents:httpcore=org.apache.httpcomponents:httpcore:jar:4.4.14:compile, commons-codec:commons-codec=commons-codec:commons-codec:jar:1.15:compile, com.fasterxml.jackson.core:jackson-databind=com.fasterxml.jackson.core:jackson-databind:jar:2.11.4:compile, com.fasterxml.jackson.core:jackson-core=com.fasterxml.jackson.core:jackson-core:jar:2.11.4:compile, org.springframework.cloud:spring-cloud-starter-openfeign=org.springframework.cloud:spring-cloud-starter-openfeign:jar:3.0.2:compile, org.springframework.cloud:spring-cloud-openfeign-core=org.springframework.cloud:spring-cloud-openfeign-core:jar:3.0.2:compile, io.github.openfeign.form:feign-form-spring=io.github.openfeign.form:feign-form-spring:jar:3.8.0:compile, io.github.openfeign.form:feign-form=io.github.openfeign.form:feign-form:jar:3.8.0:compile, commons-fileupload:commons-fileupload=commons-fileupload:commons-fileupload:jar:1.4:compile, commons-io:commons-io=commons-io:commons-io:jar:2.2:compile, org.springframework:spring-web=org.springframework:spring-web:jar:5.3.5:compile, org.springframework.cloud:spring-cloud-commons=org.springframework.cloud:spring-cloud-commons:jar:3.0.2:compile, org.springframework.security:spring-security-crypto=org.springframework.security:spring-security-crypto:jar:5.4.5:compile, io.github.openfeign:feign-core=io.github.openfeign:feign-core:jar:10.10.1:compile, io.github.openfeign:feign-slf4j=io.github.openfeign:feign-slf4j:jar:10.10.1:compile, org.springframework.boot:spring-boot-starter-validation=org.springframework.boot:spring-boot-starter-validation:jar:2.4.4:compile, org.glassfish:jakarta.el=org.glassfish:jakarta.el:jar:3.0.3:compile, org.hibernate.validator:hibernate-validator=org.hibernate.validator:hibernate-validator:jar:6.1.7.Final:compile, jakarta.validation:jakarta.validation-api=jakarta.validation:jakarta.validation-api:jar:2.0.2:compile}
[DEBUG] (s) projectBuildDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target
[DEBUG] (s) redirectTestOutputToFile = false
[DEBUG] (s) reportFormat = brief
[DEBUG] (s) reportsDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\surefire-reports
[DEBUG] (f) rerunFailingTestsCount = 2
[DEBUG] (f) reuseForks = true
[DEBUG] (s) runOrder = filesystem
[DEBUG] (s) session = org.apache.maven.execution.MavenSession@61f2c3f0
[DEBUG] (f) shutdown = testset
[DEBUG] (s) skip = false
[DEBUG] (f) skipAfterFailureCount = 10
[DEBUG] (s) skipTests = false
[DEBUG] (s) suiteXmlFiles = []
[DEBUG] (s) tempDir = surefire
[DEBUG] (s) testClassesDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\test-classes
[DEBUG] (s) testFailureIgnore = false
[DEBUG] (s) testNGArtifactName = org.testng:testng
[DEBUG] (s) testSourceDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\src\test\java
[DEBUG] (s) threadCountClasses = 0
[DEBUG] (s) threadCountMethods = 0
[DEBUG] (s) threadCountSuites = 0
[DEBUG] (s) trimStackTrace = true
[DEBUG] (s) useFile = true
[DEBUG] (s) useManifestOnlyJar = true
[DEBUG] (f) useModulePath = true
[DEBUG] (s) useSystemClassLoader = false
[DEBUG] (s) useUnlimitedThreads = false
[DEBUG] (s) workingDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess
[DEBUG] -- end configuration --
[DEBUG] Surefire report directory: C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\surefire-reports
[DEBUG] Setting system property [user.dir]=[C:\WIN-PATH\foo\foo.parent\foo.dataaccess]
[DEBUG] Setting system property [idea.version]=[2020.2.2]
[DEBUG] Setting system property [localRepository]=[C:\Develop\repository]
[DEBUG] Setting system property [basedir]=[C:\WIN-PATH\foo\foo.parent\foo.dataaccess]
[DEBUG] Using JVM: C:\DATA\Java\jdk8_u212\jre\bin\java with Java version 1.8
...
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[DEBUG] Determined Maven Process ID 16296
[DEBUG] ...
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
为什么 surefire 找不到我的测试(针对每个模块)?
从 Spring Boot 2.4 开始,JUnit 5 的老式引擎已从 spring-boot-starter-test 中删除。如果我们仍然想使用 JUnit 4 编写测试,我们需要添加以下 Maven 依赖项:
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
所以我有一个简单的项目,例如:
foo.parent
- pom.xml
- /foo.service
- pom.xml
- /src
- /main
- /java/...
- /test
- /java/some/package/TestClass.java
- /foo.common
- pom.xml
- ...
- /foo.dataaccess
- pom.xml
- ...
而 foo.parent 的 pom.xml 看起来像:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath />
</parent>
<groupId>foooooo</groupId>
<artifactId>foo.parent</artifactId>
<packaging>pom</packaging>
<version>2.31.1-SNAPSHOT</version>
<modules>
<module>foo.common</module>
<module>foo.dataaccess</module>
<module>foo.service</module>
...
</modules>
<properties>
<jdk.version>1.8</jdk.version>
...
<maven-surefire-version>3.0.0-M3</maven-surefire-version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.dataaccess</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2020.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.1.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<tag>v${releaseVersion}</tag>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<pluginManagement>
<!-- PLUGIN MANAGEMENT IS THE THING INHERITING TO SUB MODULES -->
<plugins>
<plugin>
<!-- used to run tests -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-version}</version>
<configuration>
<argLine>
-Ddetail=true
</argLine>
<!-- if more than 10 tests failed skip the rest, fix them first -->
<skipAfterFailureCount>10</skipAfterFailureCount>
<!-- if a test failed run it again, just to be sure -->
<rerunFailingTestsCount>2</rerunFailingTestsCount>
<!-- reuse the same directory as sonar -->
<reportDirectory>${sonar.junit.reportPaths}</reportDirectory>
<!-- classes directory is target/test-classes-->
<useSystemClassLoader>false</useSystemClassLoader>
<!-- atleast one test -->
<failIfNoTests>true</failIfNoTests>
</configuration>
</plugin>
<plugin>
<!-- used to report test results -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-version}</version>
</plugin>
</plugins>
</reporting>
</project>
以及任何 child 的 pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>foooooo</groupId>
<artifactId>foo.parent</artifactId>
<version>2.31.1-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<artifactId>foo.dataaccess</artifactId>
<version>2.31.1-SNAPSHOT</version>
<name>foo.dataaccess</name>
<properties>
<java.version>1.8</java.version>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
<dependencies>
<dependency>
<groupId>foooooo</groupId>
<artifactId>foo.common</artifactId>
</dependency>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
无论我做什么 maven-surefire 都不会执行任何测试,即使 testSourceDir buildOutputDirectory 等设置正确。我也没有修改任何特殊搜索词(所有测试都以 Test.java 结尾)。
如何让 surefire 打印比这更多的东西:
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ foo.dataaccess ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3, parent: sun.misc.Launcher$AppClassLoader@18b4aac2]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test' with basic configurator -->
[DEBUG] (s) additionalClasspathElements = []
[DEBUG] (s) argLine = -Ddetail=true
[DEBUG] (s) basedir = C:\WIN-PATH\foo\foo.parent\foo.dataaccess
[DEBUG] (s) childDelegation = false
[DEBUG] (s) classesDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\classes
[DEBUG] (s) classpathDependencyExcludes = []
[DEBUG] (s) dependenciesToScan = []
[DEBUG] (s) disableXmlReport = false
[DEBUG] (s) enableAssertions = true
[DEBUG] (s) encoding = UTF-8
[DEBUG] (s) failIfNoTests = true
[DEBUG] (f) forkCount = 1
[DEBUG] (s) forkMode = once
[DEBUG] (s) forkedProcessExitTimeoutInSeconds = 30
[DEBUG] (s) junitArtifactName = junit:junit
[DEBUG] (s) junitPlatformArtifactName = org.junit.platform:junit-platform-engine
[DEBUG] (s) localRepository = id: local
url: file:///C:/Develop/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]
[DEBUG] (f) parallelMavenExecution = false
[DEBUG] (s) parallelOptimized = true
[DEBUG] (s) perCoreThreadCount = true
[DEBUG] (s) pluginArtifactMap = {org.apache.maven.plugins:maven-surefire-plugin=org.apache.maven.plugins:maven-surefire-plugin:maven-plugin:3.0.0-M3:, org.apache.maven.surefire:maven-surefire-common=org.apache.maven.surefire:maven-surefire-common:jar:3.0.0-M3:compile, org.apache.maven.surefire:surefire-api=org.apache.maven.surefire:surefire-api:jar:3.0.0-M3:compile, org.apache.maven.surefire:surefire-logger-api=org.apache.maven.surefire:surefire-logger-api:jar:3.0.0-M3:compile, org.apache.maven.surefire:surefire-booter=org.apache.maven.surefire:surefire-booter:jar:3.0.0-M3:compile, org.apache.maven:maven-toolchain=org.apache.maven:maven-toolchain:jar:3.0-alpha-2:compile, org.apache.maven:maven-core=org.apache.maven:maven-core:jar:3.0:compile, org.apache.maven:maven-model=org.apache.maven:maven-model:jar:3.0:compile, org.apache.maven:maven-settings=org.apache.maven:maven-settings:jar:3.0:compile, org.apache.maven:maven-settings-builder=org.apache.maven:maven-settings-builder:jar:3.0:compile, org.apache.maven:maven-repository-metadata=org.apache.maven:maven-repository-metadata:jar:3.0:compile, org.apache.maven:maven-artifact=org.apache.maven:maven-artifact:jar:3.0:compile, org.apache.maven:maven-plugin-api=org.apache.maven:maven-plugin-api:jar:3.0:compile, org.apache.maven:maven-model-builder=org.apache.maven:maven-model-builder:jar:3.0:compile, org.apache.maven:maven-aether-provider=org.apache.maven:maven-aether-provider:jar:3.0:runtime, org.sonatype.aether:aether-impl=org.sonatype.aether:aether-impl:jar:1.7:compile, org.sonatype.aether:aether-spi=org.sonatype.aether:aether-spi:jar:1.7:compile, org.sonatype.aether:aether-api=org.sonatype.aether:aether-api:jar:1.7:compile, org.sonatype.aether:aether-util=org.sonatype.aether:aether-util:jar:1.7:compile, org.sonatype.sisu:sisu-inject-plexus=org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile, org.sonatype.sisu:sisu-inject-bean=org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile, org.sonatype.sisu:sisu-guice=org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile, org.codehaus.plexus:plexus-interpolation=org.codehaus.plexus:plexus-interpolation:jar:1.14:compile, org.codehaus.plexus:plexus-utils=org.codehaus.plexus:plexus-utils:jar:2.0.4:compile, org.codehaus.plexus:plexus-classworlds=org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile, org.codehaus.plexus:plexus-component-annotations=org.codehaus.plexus:plexus-component-annotations:jar:1.7.1:compile, org.sonatype.plexus:plexus-sec-dispatcher=org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile, org.sonatype.plexus:plexus-cipher=org.sonatype.plexus:plexus-cipher:jar:1.4:compile, org.apache.maven:maven-compat=org.apache.maven:maven-compat:jar:3.0:compile, org.apache.maven.wagon:wagon-provider-api=org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile, org.codehaus.plexus:plexus-java=org.codehaus.plexus:plexus-java:jar:1.0.1:compile, org.ow2.asm:asm=org.ow2.asm:asm:jar:7.0-beta:compile, com.thoughtworks.qdox:qdox=com.thoughtworks.qdox:qdox:jar:2.0-M9:compile}
[DEBUG] (f) pluginDescriptor = Component Descriptor: role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugin.surefire.HelpMojo', role hint: 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:help'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugin.surefire.SurefirePlugin', role hint: 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test'
---
[DEBUG] (s) printSummary = true
[DEBUG] (s) project = MavenProject: some.package.foo:foo.dataaccess:2.31.1-SNAPSHOT @ C:\WIN-PATH\foo\foo.parent\foo.dataaccess\pom.xml
[DEBUG] (s) projectArtifactMap = {org.springframework.boot:spring-boot-starter-data-jpa=org.springframework.boot:spring-boot-starter-data-jpa:jar:2.4.4:compile, org.springframework.boot:spring-boot-starter-aop=org.springframework.boot:spring-boot-starter-aop:jar:2.4.4:compile, org.aspectj:aspectjweaver=org.aspectj:aspectjweaver:jar:1.9.6:compile, org.springframework.boot:spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc:jar:2.4.4:compile, com.zaxxer:HikariCP=com.zaxxer:HikariCP:jar:3.4.5:compile, org.springframework:spring-jdbc=org.springframework:spring-jdbc:jar:5.3.5:compile, jakarta.transaction:jakarta.transaction-api=jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile, jakarta.persistence:jakarta.persistence-api=jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile, org.hibernate:hibernate-core=org.hibernate:hibernate-core:jar:5.4.29.Final:compile, org.jboss.logging:jboss-logging=org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile, org.javassist:javassist=org.javassist:javassist:jar:3.27.0-GA:compile, net.bytebuddy:byte-buddy=net.bytebuddy:byte-buddy:jar:1.10.22:compile, antlr:antlr=antlr:antlr:jar:2.7.7:compile, org.jboss:jandex=org.jboss:jandex:jar:2.2.3.Final:compile, com.fasterxml:classmate=com.fasterxml:classmate:jar:1.5.1:compile, org.dom4j:dom4j=org.dom4j:dom4j:jar:2.1.3:compile, org.hibernate.common:hibernate-commons-annotations=org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile, org.glassfish.jaxb:jaxb-runtime=org.glassfish.jaxb:jaxb-runtime:jar:2.3.3:compile, org.glassfish.jaxb:txw2=org.glassfish.jaxb:txw2:jar:2.3.3:compile, com.sun.istack:istack-commons-runtime=com.sun.istack:istack-commons-runtime:jar:3.0.11:compile, com.sun.activation:jakarta.activation=com.sun.activation:jakarta.activation:jar:1.2.2:runtime, org.springframework.data:spring-data-jpa=org.springframework.data:spring-data-jpa:jar:2.4.6:compile, org.springframework.data:spring-data-commons=org.springframework.data:spring-data-commons:jar:2.4.6:compile, org.springframework:spring-orm=org.springframework:spring-orm:jar:5.3.5:compile, org.springframework:spring-context=org.springframework:spring-context:jar:5.3.5:compile, org.springframework:spring-tx=org.springframework:spring-tx:jar:5.3.5:compile, org.springframework:spring-beans=org.springframework:spring-beans:jar:5.3.5:compile, org.springframework:spring-aspects=org.springframework:spring-aspects:jar:5.3.5:compile, org.springframework.boot:spring-boot-starter-security=org.springframework.boot:spring-boot-starter-security:jar:2.4.4:compile, org.springframework.boot:spring-boot-starter=org.springframework.boot:spring-boot-starter:jar:2.4.4:compile, org.springframework.boot:spring-boot=org.springframework.boot:spring-boot:jar:2.4.4:compile, org.springframework.boot:spring-boot-autoconfigure=org.springframework.boot:spring-boot-autoconfigure:jar:2.4.4:compile, org.springframework.boot:spring-boot-starter-logging=org.springframework.boot:spring-boot-starter-logging:jar:2.4.4:compile, ch.qos.logback:logback-classic=ch.qos.logback:logback-classic:jar:1.2.3:compile, ch.qos.logback:logback-core=ch.qos.logback:logback-core:jar:1.2.3:compile, org.apache.logging.log4j:log4j-to-slf4j=org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.3:compile, org.apache.logging.log4j:log4j-api=org.apache.logging.log4j:log4j-api:jar:2.13.3:compile, org.slf4j:jul-to-slf4j=org.slf4j:jul-to-slf4j:jar:1.7.30:compile, jakarta.annotation:jakarta.annotation-api=jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile, org.yaml:snakeyaml=org.yaml:snakeyaml:jar:1.27:compile, org.springframework:spring-aop=org.springframework:spring-aop:jar:5.3.5:compile, org.springframework.security:spring-security-config=org.springframework.security:spring-security-config:jar:5.4.5:compile, org.springframework.security:spring-security-web=org.springframework.security:spring-security-web:jar:5.4.5:compile, org.springframework:spring-expression=org.springframework:spring-expression:jar:5.3.5:compile, org.springframework.boot:spring-boot-starter-test=org.springframework.boot:spring-boot-starter-test:jar:2.4.4:test, org.springframework.boot:spring-boot-test=org.springframework.boot:spring-boot-test:jar:2.4.4:test, org.springframework.boot:spring-boot-test-autoconfigure=org.springframework.boot:spring-boot-test-autoconfigure:jar:2.4.4:test, com.jayway.jsonpath:json-path=com.jayway.jsonpath:json-path:jar:2.4.0:test, net.minidev:json-smart=net.minidev:json-smart:jar:2.3:test, net.minidev:accessors-smart=net.minidev:accessors-smart:jar:1.2:test, org.ow2.asm:asm=org.ow2.asm:asm:jar:5.0.4:test, jakarta.xml.bind:jakarta.xml.bind-api=jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile, jakarta.activation:jakarta.activation-api=jakarta.activation:jakarta.activation-api:jar:1.2.2:compile, org.assertj:assertj-core=org.assertj:assertj-core:jar:3.18.1:test, org.hamcrest:hamcrest=org.hamcrest:hamcrest:jar:2.2:test, org.junit.jupiter:junit-jupiter=org.junit.jupiter:junit-jupiter:jar:5.7.1:test, org.junit.jupiter:junit-jupiter-api=org.junit.jupiter:junit-jupiter-api:jar:5.7.1:test, org.apiguardian:apiguardian-api=org.apiguardian:apiguardian-api:jar:1.1.0:test, org.opentest4j:opentest4j=org.opentest4j:opentest4j:jar:1.2.0:test, org.junit.platform:junit-platform-commons=org.junit.platform:junit-platform-commons:jar:1.7.1:test, org.junit.jupiter:junit-jupiter-params=org.junit.jupiter:junit-jupiter-params:jar:5.7.1:test, org.junit.jupiter:junit-jupiter-engine=org.junit.jupiter:junit-jupiter-engine:jar:5.7.1:test, org.junit.platform:junit-platform-engine=org.junit.platform:junit-platform-engine:jar:1.7.1:test, org.mockito:mockito-core=org.mockito:mockito-core:jar:3.6.28:test, net.bytebuddy:byte-buddy-agent=net.bytebuddy:byte-buddy-agent:jar:1.10.22:test, org.objenesis:objenesis=org.objenesis:objenesis:jar:3.1:test, org.mockito:mockito-junit-jupiter=org.mockito:mockito-junit-jupiter:jar:3.6.28:test, org.skyscreamer:jsonassert=org.skyscreamer:jsonassert:jar:1.5.0:test, com.vaadin.external.google:android-json=com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test, org.springframework:spring-core=org.springframework:spring-core:jar:5.3.5:compile, org.springframework:spring-jcl=org.springframework:spring-jcl:jar:5.3.5:compile, org.springframework:spring-test=org.springframework:spring-test:jar:5.3.5:test, org.xmlunit:xmlunit-core=org.xmlunit:xmlunit-core:jar:2.7.0:test, org.projectlombok:lombok=org.projectlombok:lombok:jar:1.18.18:compile, com.ibm.db2:db2jcc4=com.ibm.db2:db2jcc4:jar:4.25.13:compile, com.h2database:h2=com.h2database:h2:jar:1.4.200:compile, some.package.foo:foo.common=some.package.foo:foo.common:jar:2.31.1-SNAPSHOT:compile, org.springframework:spring-context-support=org.springframework:spring-context-support:jar:5.3.5:compile, org.springframework.security:spring-security-core=org.springframework.security:spring-security-core:jar:5.4.5:compile, junit:junit=junit:junit:jar:4.13.2:test, org.hamcrest:hamcrest-core=org.hamcrest:hamcrest-core:jar:2.2:test, org.apache.commons:commons-lang3=org.apache.commons:commons-lang3:jar:3.11:compile, org.apache.commons:commons-collections4=org.apache.commons:commons-collections4:jar:4.4:compile, com.auth0:java-jwt=com.auth0:java-jwt:jar:2.1.0:compile, net.sf.ehcache:ehcache=net.sf.ehcache:ehcache:jar:2.10.0:compile, org.slf4j:slf4j-api=org.slf4j:slf4j-api:jar:1.7.30:compile, net.bull.javamelody:javamelody-spring-boot-starter=net.bull.javamelody:javamelody-spring-boot-starter:jar:1.86.0:compile, net.bull.javamelody:javamelody-core=net.bull.javamelody:javamelody-core:jar:1.86.0:compile, org.jrobin:jrobin=org.jrobin:jrobin:jar:1.5.9:compile, commons-dbcp:commons-dbcp=commons-dbcp:commons-dbcp:jar:1.4:compile, commons-pool:commons-pool=commons-pool:commons-pool:jar:1.6:compile, org.databene:contiperf=org.databene:contiperf:jar:2.1.0:test, org.hsqldb:hsqldb=org.hsqldb:hsqldb:jar:2.3.3:compile, org.mapstruct:mapstruct=org.mapstruct:mapstruct:jar:1.4.1.Final:compile, org.liquibase:liquibase-core=org.liquibase:liquibase-core:jar:3.10.3:compile, javax.xml.bind:jaxb-api=javax.xml.bind:jaxb-api:jar:2.3.1:compile, javax.activation:javax.activation-api=javax.activation:javax.activation-api:jar:1.2.0:compile, org.springframework.cloud:spring-cloud-starter-config=org.springframework.cloud:spring-cloud-starter-config:jar:3.0.3:compile, org.springframework.cloud:spring-cloud-starter=org.springframework.cloud:spring-cloud-starter:jar:3.0.2:compile, org.springframework.cloud:spring-cloud-context=org.springframework.cloud:spring-cloud-context:jar:3.0.2:compile, org.springframework.security:spring-security-rsa=org.springframework.security:spring-security-rsa:jar:1.0.9.RELEASE:compile, org.bouncycastle:bcpkix-jdk15on=org.bouncycastle:bcpkix-jdk15on:jar:1.64:compile, org.bouncycastle:bcprov-jdk15on=org.bouncycastle:bcprov-jdk15on:jar:1.64:compile, org.springframework.cloud:spring-cloud-config-client=org.springframework.cloud:spring-cloud-config-client:jar:3.0.3:compile, com.fasterxml.jackson.core:jackson-annotations=com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile, org.apache.httpcomponents:httpclient=org.apache.httpcomponents:httpclient:jar:4.5.13:compile, org.apache.httpcomponents:httpcore=org.apache.httpcomponents:httpcore:jar:4.4.14:compile, commons-codec:commons-codec=commons-codec:commons-codec:jar:1.15:compile, com.fasterxml.jackson.core:jackson-databind=com.fasterxml.jackson.core:jackson-databind:jar:2.11.4:compile, com.fasterxml.jackson.core:jackson-core=com.fasterxml.jackson.core:jackson-core:jar:2.11.4:compile, org.springframework.cloud:spring-cloud-starter-openfeign=org.springframework.cloud:spring-cloud-starter-openfeign:jar:3.0.2:compile, org.springframework.cloud:spring-cloud-openfeign-core=org.springframework.cloud:spring-cloud-openfeign-core:jar:3.0.2:compile, io.github.openfeign.form:feign-form-spring=io.github.openfeign.form:feign-form-spring:jar:3.8.0:compile, io.github.openfeign.form:feign-form=io.github.openfeign.form:feign-form:jar:3.8.0:compile, commons-fileupload:commons-fileupload=commons-fileupload:commons-fileupload:jar:1.4:compile, commons-io:commons-io=commons-io:commons-io:jar:2.2:compile, org.springframework:spring-web=org.springframework:spring-web:jar:5.3.5:compile, org.springframework.cloud:spring-cloud-commons=org.springframework.cloud:spring-cloud-commons:jar:3.0.2:compile, org.springframework.security:spring-security-crypto=org.springframework.security:spring-security-crypto:jar:5.4.5:compile, io.github.openfeign:feign-core=io.github.openfeign:feign-core:jar:10.10.1:compile, io.github.openfeign:feign-slf4j=io.github.openfeign:feign-slf4j:jar:10.10.1:compile, org.springframework.boot:spring-boot-starter-validation=org.springframework.boot:spring-boot-starter-validation:jar:2.4.4:compile, org.glassfish:jakarta.el=org.glassfish:jakarta.el:jar:3.0.3:compile, org.hibernate.validator:hibernate-validator=org.hibernate.validator:hibernate-validator:jar:6.1.7.Final:compile, jakarta.validation:jakarta.validation-api=jakarta.validation:jakarta.validation-api:jar:2.0.2:compile}
[DEBUG] (s) projectBuildDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target
[DEBUG] (s) redirectTestOutputToFile = false
[DEBUG] (s) reportFormat = brief
[DEBUG] (s) reportsDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\surefire-reports
[DEBUG] (f) rerunFailingTestsCount = 2
[DEBUG] (f) reuseForks = true
[DEBUG] (s) runOrder = filesystem
[DEBUG] (s) session = org.apache.maven.execution.MavenSession@61f2c3f0
[DEBUG] (f) shutdown = testset
[DEBUG] (s) skip = false
[DEBUG] (f) skipAfterFailureCount = 10
[DEBUG] (s) skipTests = false
[DEBUG] (s) suiteXmlFiles = []
[DEBUG] (s) tempDir = surefire
[DEBUG] (s) testClassesDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\test-classes
[DEBUG] (s) testFailureIgnore = false
[DEBUG] (s) testNGArtifactName = org.testng:testng
[DEBUG] (s) testSourceDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess\src\test\java
[DEBUG] (s) threadCountClasses = 0
[DEBUG] (s) threadCountMethods = 0
[DEBUG] (s) threadCountSuites = 0
[DEBUG] (s) trimStackTrace = true
[DEBUG] (s) useFile = true
[DEBUG] (s) useManifestOnlyJar = true
[DEBUG] (f) useModulePath = true
[DEBUG] (s) useSystemClassLoader = false
[DEBUG] (s) useUnlimitedThreads = false
[DEBUG] (s) workingDirectory = C:\WIN-PATH\foo\foo.parent\foo.dataaccess
[DEBUG] -- end configuration --
[DEBUG] Surefire report directory: C:\WIN-PATH\foo\foo.parent\foo.dataaccess\target\surefire-reports
[DEBUG] Setting system property [user.dir]=[C:\WIN-PATH\foo\foo.parent\foo.dataaccess]
[DEBUG] Setting system property [idea.version]=[2020.2.2]
[DEBUG] Setting system property [localRepository]=[C:\Develop\repository]
[DEBUG] Setting system property [basedir]=[C:\WIN-PATH\foo\foo.parent\foo.dataaccess]
[DEBUG] Using JVM: C:\DATA\Java\jdk8_u212\jre\bin\java with Java version 1.8
...
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[DEBUG] Determined Maven Process ID 16296
[DEBUG] ...
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
为什么 surefire 找不到我的测试(针对每个模块)?
从 Spring Boot 2.4 开始,JUnit 5 的老式引擎已从 spring-boot-starter-test 中删除。如果我们仍然想使用 JUnit 4 编写测试,我们需要添加以下 Maven 依赖项:
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>