简体   繁体   中英

Run testng tests from parent pom

I am trying to run TestNG Selenium tests from parent pom. When I run the command mvn install BUILD SUCCESSFUL message is shown, but the tests aren't run.

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.

The Parent pom.xml file looks like:

<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

<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 . This project depends on 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM