我的qa
中有这个Maven个人资料pom.xml
。它没有运行。它应该将env.properties
的文件复制到/root/target/classes
,但不是。
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<copy file="src/main/resources/qa.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
我还有另一个示例项目,其中的概要文件运行得很好。
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="${project.build.outputDirectory}" includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/qa.properties" tofile="${project.build.outputDirectory}/env.properties"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
用于构建的命令
mvn verify -Pqa -Dwebdriver.driver=chrome -e
更新的POM:
我不想弄乱Maven故障安全插件。另外,我还需要一些对整个生命周期不感兴趣的属性文件。因此,现在我正在使用两个插件maven-failsafe-plugin
来运行常规clean, verify
任务,并且仅运行maven-antrun-plugin
,并且仅在maven-failsafe-plugin
开始之前复制属性文件。
在POM下面是如果删除配置文件,则可以工作,即如果我在profiles
下没有maven-antrun-plugin
,则使用以下命令复制属性文件
mvn clean test verify -Dwebdriver.driver=chrome -Dcucumber.options="--tags @sanity" -e
但是,如果我创建配置文件,则它不会复制
mvn clean test -Pqa verify -Dwebdriver.driver=chrome -Dcucumber.options="--tags @sanity" -e
如何使个人资料在这里工作?我执行了错误的命令吗?
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.automation</groupId>
<artifactId>serenity-automation-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Serenity Cucumber and WebDriver</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>2.0.18</serenity.version>
<serenity.cucumber.version>1.6.6</serenity.cucumber.version>
<webdriver.driver>firefox</webdriver.driver>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<profiles>
<profile>
<id>qa</id>
<target>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/qa.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</target>
</profile>
<profile>
<id>stage</id>
<target>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/stage.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</target>
</profile>
<profile>
<id>prod</id>
<target>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/prod.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</target>
</profile>
</profiles>
</configuration>
<!-- <goals> <goal>run</goal> </goals> -->
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:1)
配置tasks(不建议使用,改为使用 target )来自插件maven-antrun-plugin。
因此,不能像您的第一个示例那样在插件maven-failsafe-plugin中使用它。