如何从命令行在Intellij idea中运行testng appium java maven项目构建?
我有一个maven项目appium/java,它是用Intellij idea编写的。要运行测试,我必须运行testng.xml文件。如何从命令行在Intellij idea中运行testng appium java maven项目构建?,maven,intellij-idea,command-line,testng,appium,Maven,Intellij Idea,Command Line,Testng,Appium,我有一个maven项目appium/java,它是用Intellij idea编写的。要运行测试,我必须运行testng.xml文件。 我想从命令行运行测试脚本。我该怎么做?我找到了从命令行运行testng.xml的各种链接,但没有一种解决方案适合我。提前感谢因为您的是一个maven项目,您可以在导航到项目路径后从命令行使用选项mvn clean test。这将在testng.xml文件中运行测试 如果您有多个测试xml文件,则可以使用。在pom.xml中,您需要添加以下内容: <
我想从命令行运行测试脚本。我该怎么做?我找到了从命令行运行testng.xml的各种链接,但没有一种解决方案适合我。提前感谢因为您的是一个maven项目,您可以在导航到项目路径后从命令行使用选项mvn clean test。这将在testng.xml文件中运行测试 如果您有多个测试xml文件,则可以使用。在pom.xml中,您需要添加以下内容:
<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>
如果要运行多个测试xml文件,可以使用以下命令
mvn clean test -DsuiteXmlFile.suiteXmlFiles=path/to/test1.xml
mvn clean test -DsuiteXmlFile.suiteXmlFiles=path/to/test1.xml,path/to/test2.xml
希望这对您有所帮助如果您使用testng.xml文件运行appium案例,那么您可以使用maven的surefire插件使用maven运行testng文件。maven可以使用命令行运行 因此,基本上您可以运行maven命令,该命令将使用surefire插件在内部运行tesng.xml文件。在构建部分的pom文件中添加surefire插件,如下所示。然后运行mvn test命令,它就可以工作了
<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>
我没有得到你的答案。你能详细说明一下吗?我的意思是你可以使用maven命令来实现这一点。首先在命令行中导航到您的项目,然后运行命令mvn clean test。这将在testng.xml文件中运行测试。我有多个xml文件,如test1.xml、test2.xml等。如何运行?如果我只想要ren test1.xml文件,我该怎么做?