如何使用jmeter maven插件运行特定的jmx文件

如何使用jmeter maven插件运行特定的jmx文件,maven,jmeter,jmeter-maven-plugin,Maven,Jmeter,Jmeter Maven Plugin,我正在使用jmetermaven插件()在我的Maven项目中触发jmx文件。 是否有一种方法可以指定在运行时运行哪个jmx文件,而不是在pom.xml中指定插件配置testFilesDirectory、testFilesExcluded、testFilesIncluded等。 在jmeter命令行模式中,我们可以使用-t指定 jmeter-n-t mytest.jmx jmeter maven插件中是否有类似的选项此标签有什么问题 如果你定义一个like 或 完整的pom.xml文件以防万一:

我正在使用jmetermaven插件()在我的Maven项目中触发jmx文件。 是否有一种方法可以指定在运行时运行哪个jmx文件,而不是在pom.xml中指定插件配置testFilesDirectory、testFilesExcluded、testFilesIncluded等。 在jmeter命令行模式中,我们可以使用-t指定

jmeter-n-t mytest.jmx

jmeter maven插件中是否有类似的选项此标签有什么问题

如果你定义一个like

完整的pom.xml文件以防万一:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>jmeter</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <jmeterScript>test1.jmx</jmeterScript>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.8.5</version>
                <executions>
                    <!-- Run JMeter tests -->
                    <execution>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                    <!-- Fail build on errors in test -->
                    <execution>
                        <id>jmeter-check-results</id>
                        <goals>
                            <goal>results</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <testFilesIncluded>
                        <jMeterTestFile>${jmeterScript}</jMeterTestFile>
                    </testFilesIncluded>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

4.0.0
com.example

  • <configuration>
        <testFilesIncluded>
            <jMeterTestFile>${jmeterScript}</jMeterTestFile>
        </testFilesIncluded>
    </configuration>
    
    mvn -DjmeterScript=someTest.jmx clean verify
    
    mvn -DjmeterScript=someOtherTest clean verify 
    
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.example</groupId>
        <artifactId>jmeter</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <properties>
            <jmeterScript>test1.jmx</jmeterScript>
        </properties>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.8.5</version>
                    <executions>
                        <!-- Run JMeter tests -->
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                        <!-- Fail build on errors in test -->
                        <execution>
                            <id>jmeter-check-results</id>
                            <goals>
                                <goal>results</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <testFilesIncluded>
                            <jMeterTestFile>${jmeterScript}</jMeterTestFile>
                        </testFilesIncluded>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    </project>