我尝试运行仍然失败的单元测试。最大的问题-也许我只是不明白怎么可能-当我尝试运行测试时,我看到它尝试在错误的项目上运行。
运行时:
mvn test -Dtest=com.alphad.cdees.backend.test.logic.BuyLogicTest
我收到此错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project cdees-core: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :cdees-core
我不明白为什么它会尝试在 cdees-core 项目而不是 cdees-backend 项目上运行此测试-我在其中具有单元测试类< strong> BuyLogicTest 。
这是项目的配置: '
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>cdees-parent</artifactId>
<groupId>com.alphad.cdees</groupId>
<version>3.14.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdees-backend</artifactId>
<packaging>jar</packaging>
<properties>
<main.basedir>${project.parent.basedir}</main.basedir>
<postgres.jdbc.version>42.2.5</postgres.jdbc.version>
<cdees.postgres.ipAddress>${docker.container.postgres-mysoftware-backend-test.ip}</cdees.postgres.ipAddress>
<docker.disable>${skipTests}</docker.disable>
<!-- Containers name identified globally by their alias set in the build configuration -->
<docker.containerNamePattern>%a</docker.containerNamePattern>
</properties>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<!--
Enable this plugin for code coverage measurement
NOTE: the plugin put an additional member ($jaCoCo) in each
class, making some unit test to fail
-->
<!--
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<!-- Propagate project properties to system properties in the forked executor -->
<systemPropertyVariables>
<cdees.postgres.ipAddress>${cdees.postgres.ipAddress}</cdees.postgres.ipAddress>
<cdees.postgres.port>${cdees.postgres.port}</cdees.postgres.port>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<!-- See https://dmp.fabric8.io/ -->
<version>0.27.2</version>
<configuration>
<!-- change here if you are using another port/host, e.g. 4243 -->
<dockerHost>tcp://localhost:2375</dockerHost>
<skip>${docker.disable}</skip>
<!-- Enable this for debugging docker image/container evolution -->
<verbose>false</verbose>
<images>
<image>
<name>postgres:mysoftware-backend-test</name>
<alias>postgres-mysoftware-backend-test</alias>
<build>
<nocache>true</nocache>
<dockerFileDir>postgres</dockerFileDir>
<assembly>
<!-- The assembly name is referenced in the Dockerfile -->
<name>db-files</name>
<inline>
<!-- These files cannot be accessed by the image builder, we need
for them to create a special maven-assembly accessor -->
<files>
<file><source>../db/GeoIPCountryWhois.csv</source></file>
<file><source>../db/schema.sql</source></file>
</files>
</inline>
</assembly>
</build>
<run>
<wait>
<time>60000</time>
<tcp>
<host>${cdees.postgres.ipAddress}</host>
<ports>
<port>${cdees.postgres.port}</port>
</ports>
</tcp>
<!-- This is a real test, server side, stating that the server is ready -->
<exec>
<breakOnError>true</breakOnError>
<postStart>
wait_for_pg_server.sh
</postStart>
</exec>
</wait>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>help</goal>
</goals>
</execution>
<execution>
<id>docker-build-img-start-cnt</id>
<phase>test-compile</phase>
<goals>
<goal>stop</goal>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-stop-cnt-rm-img</id>
<phase>test</phase>
<goals>
<goal>stop</goal>
<goal>remove</goal>
</goals>
</execution>
<execution>
<id>docker-rm-img</id>
<phase>clean</phase>
<goals>
<goal>stop</goal>
<goal>remove</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.jdbc.version}</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<skip>${skipTests}</skip>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://${cdees.postgres.ipAddress}:${cdees.postgres.port}/silentdefense</url>
<username>user</username>
<password>pass</password>
<!-- You can comment out username/password configurations and
have maven to look them up in your settings.xml using ${settingsKey}
-->
<delimiterType>row</delimiterType>
<autocommit>true</autocommit>
</configuration>
<executions>
<execution>
<id>create-data</id>
<phase>test-compile</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<orderFile>ascending</orderFile>
<fileset>
<basedir>${project.basedir}</basedir>
<includes>
<include>src/test/resources/UnitTestDBData.sql</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Our own libraries -->
<dependency>
<groupId>com.alphad.cdees</groupId>
<artifactId>cdees-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.alphad.cdees</groupId>
<artifactId>cdees-core</artifactId>
<type>test-jar</type>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alphad.cdees</groupId>
<artifactId>cdees-driver-scp</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.alphad.cdees</groupId>
<artifactId>cdees-driver-scp</artifactId>
<type>test-jar</type>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<!-- Third party libraries -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.6</version>
</dependency>
<dependency>
<groupId>org.hyperic</groupId>
<artifactId>sigar</artifactId>
<version>1.7-SVN</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jrobin</groupId>
<artifactId>jrobin</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.jdbc.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.druid</groupId>
<artifactId>druid-processing</artifactId>
<version>0.8.1</version>
<exclusions>
<exclusion>
<artifactId>log4j-slf4j-impl</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-core</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-jul</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-1.2-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2.1</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<!--
This dependency exclusion was removed in 3.13.0 to support the KafkaForwarderService
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
-->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>net.jpountz.lz4</groupId>
<artifactId>lz4</artifactId>
</exclusion>
<!--
This dependency exclusion was removed in 3.13.0 to support the KafkaForwarderService
<exclusion>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
</exclusion>
-->
<exclusion>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.5.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>com.googlecode.protobuf-java-format</groupId>
<artifactId>protobuf-java-format</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
<version>${unboundid-ldapsdk.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
'
已解决,我尝试在错误的目录中运行它。
答案 0 :(得分:1)
尝试一下:
答案 1 :(得分:0)
如果您的后端依赖于内核,它将首先执行验证,编译,测试和jar任务的过程,以便可以在后端中使用它。 Maven Build Lifecycle