簡體   English   中英

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

[英]how to run a specific jmx file using jmeter maven plugin

我正在使用 Jmeter Maven 插件( http://jmeter.lazerycode.com )來觸發我的 Maven 項目中的 jmx 文件。 有沒有一種方法可以指定在運行時運行哪個 jmx 文件,而不是 pom.xml 中的插件配置 testFilesDirectory、testFilesExcluded、testFilesIncluded 等。 在 jmeter 命令行模式下,我們可以使用 -t 指定。

jmeter -n -t mytest.jmx

jmeter maven插件中是否有類似的選項

這個<testFilesIncluded>標簽有什么問題?

如果您定義了一個Maven 屬性,例如

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

並在 JMeter Maven 插件中將其引用為:

<configuration>
    <testFilesIncluded>
        <jMeterTestFile>${jmeterScript}</jMeterTestFile>
    </testFilesIncluded>
</configuration>

您將能夠使用-D命令行參數覆蓋屬性值,例如:

mvn -DjmeterScript=someTest.jmx clean verify

或者

mvn -DjmeterScript=someOtherTest clean verify 

完整的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>

更多信息:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM