[英]Run testng tests from parent pom
I am trying to run TestNG Selenium tests from parent pom. 我正在尝试从父pom运行TestNG Selenium测试。 When I run the command
mvn install
BUILD SUCCESSFUL message is shown, but the tests aren't run. 当我运行命令
mvn install
BUILD SUCCESSFUL消息,但未运行测试。
Following is my folder structure: 以下是我的文件夹结构:
Parent
|----Child1
| |---src
| |---pom.xml
|----Child2
| |---src
| |---pom.xml
| |---myTests.xml
|-pom.xml
When the command mvn install
is run from Child2 folder without any changes, then the tests are run. 如果从Child2文件夹运行了命令
mvn install
而未进行任何更改,则将运行测试。
The Parent pom.xml
file looks like: 父
pom.xml
文件如下所示:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.parent</groupId>
<artifactId>parent</artifactId>
<version>1</version>
<packaging>pom</packaging>
<profiles>
<profile>
<modules>
<module>Child1</module>
<module>Child2</module>
</modules>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<skipTests>false</skipTests>
<suiteXmlFiles>
<suiteXmlFile>myTests.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Child1 - pom.xml
子1-
pom.xml
<parent>
<groupId>com.example.parent<groupId>
<artifactId>parent</artifactId>
<version>1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.parent</groupId>
<artifactId>Child1</artifactId>
<version>1</version>
Child2 - pom.xml
. Child2-
pom.xml
。 This project depends on Child1 该项目取决于Child1
<parent>
<groupId>com.example.parent</groupId>
<artifactId>parent</artifactId>
<version>1</version>
</parent>
<groupId>com.example.parent</groupId>
<artifactId>Child2</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>com.example.parent</groupId>
<artifactId>Child1</artifactId>
<version>1</version>
</dependency>
</dependencies>
我在父pom的插件下添加了以下代码,并为我运行了测试。
<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.