首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Intellij中从命令行运行testng appium-java maven项目?

如何在Intellij中从命令行运行testng appium-java maven项目?
EN

Stack Overflow用户
提问于 2019-01-02 10:36:23
回答 2查看 1.1K关注 0票数 0

我有一个maven项目(appium/java),它是用Intellij编写的。要运行测试,我必须运行testng.xml文件。我想从命令行运行我的测试脚本。我怎么能这么做?我已经找到了从命令行运行testng.xml的各种链接,但是没有一个解决方案适合我。提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-01-02 10:51:26

由于您的maven项目,您可以在导航到您的项目路径后从命令行使用选项mvn干净测试。这将在testng.xml文件中运行测试。

如果您有多个测试xml文件,则可以使用万岁插件。在您的pom.xml中需要添加如下内容:

代码语言:javascript
复制
     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M3</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>${suiteXmlFiles}</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>

添加所需的多个suiteXmlFile标记&它应该指向test1.xml、test2.xml等的位置,然后在命令行中使用以下命令

代码语言:javascript
复制
mvn clean test -DsuiteXmlFile.suiteXmlFiles=path/to/test1.xml

如果要运行多个测试xml文件,可以使用以下命令

代码语言:javascript
复制
mvn clean test -DsuiteXmlFile.suiteXmlFiles=path/to/test1.xml,path/to/test2.xml

希望这能有所帮助

票数 1
EN

Stack Overflow用户

发布于 2019-01-07 03:44:35

如果您正在使用testng.xml文件运行appium案例,那么您可以使用maven的尽力而为的插件来使用maven运行testng文件。maven,您可以使用命令行运行。

因此,基本上您可以运行maven命令,它将在内部使用尽力而为的插件运行您的tesng.xml文件。在构建部分中的pom文件中添加这样的插件,如下所示。然后运行mvn测试命令,它将工作。

代码语言:javascript
复制
<build>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>Give your testng.xml file   path</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54004797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档