简体   繁体   English

从父pom运行testng测试

[英]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.

相关问题 如何使用Maven POM文件运行testNG测试 - How to run testNG tests using Maven POM file 是否可以将 pom.xml 设置为从命令行分别运行 testNG(UI 性能测试)测试和 jUnit(单元测试)测试? - Can pom.xml be set up to run testNG(UI perf. tests) tests and jUnit(unit tests) tests separately, from command line? 无法从 Maven 运行 testNG 测试 - Unable to run testNG tests from maven 当我使用 maven-surefire 使用 POM 文件执行 testng.xml 时,TestNG 测试没有运行 - TestNG tests are not getting run when I execute testng.xml using POM file using maven-surefire 如何从父pom&#39;mvn jetty:run&#39;? - How to 'mvn jetty:run' from a parent pom? 在执行selenium测试期间,testng.xml没有从pom.xml运行 - testng.xml is not running from pom.xml during executing selenium tests 从 POM.xml 运行 Testng.xml 未按顺序运行测试 - Running Testng.xml from POM.xml is not running tests in sequence 如何通过单击Web界面触发Junit / Testng测试运行 - How to trigger the Junit/Testng tests to run by clicking from a web interface 与surefire和testng并行运行测试 - Run tests in parallel with surefire and testng Selenium TestNG:如何使用TestNG从编译的jar运行selenium测试? - Selenium TestNG: How can I run selenium tests from a compiled jar using TestNG?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM