【问题标题】:Setting JMeter properties from Maven plugin从 Maven 插件设置 JMeter 属性
【发布时间】:2016-09-21 06:58:07
【问题描述】:

我正在尝试使用 Maven 插件为 JMeter 测试设置属性。我已经按照pom.xml 文件中推荐的设置从this question 的答案中获取,但是在运行测试时我的属性没有被拾取。

pom.xml的相关部分:

<profiles>
    <profile>
        <id>jmeter-test</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                            <configuration>
                                <propertiesUser>
                                    <threadCount>5</threadCount>
                                    <environment>test</environment>
                                </propertiesUser>
                                <testResultsTimestamp>false</testResultsTimestamp>
                                <proxyConfig>
                                    <host>localhost</host>
                                    <port>8888</port>
                                </proxyConfig>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

我正在尝试使用 ${__P(threadCount)}${__P(environment)} 访问我的 JMeter 测试中的变量。

跑步时,我正在使用

mvn clean verify -Pjmeter-tests

我可以看到正在从输出中提取和使用代理配置:

[INFO] -------------------------------------------------------
[INFO]  P E R F O R M A N C E    T E S T S
[INFO] -------------------------------------------------------
[INFO] Invalid value detected for <postTestPauseInSeconds>.  Setting pause to 0...
[INFO]
[INFO] Proxy Details:

Host: localhost:8888


[INFO]
[INFO] Executing test: JMeterTests.jmx

不幸的是,propertiesUser 值没有被使用。我还可以使用命令行运行程序,它按预期工作:

jmeter -n -t JMeterTests.jmx -Jenvironment=test -JthreadCount=5

关于为什么这不起作用的任何想法?

更多信息: 我一直在使用example project 进行测试,看到预期的行为是&lt;propertiesUser&gt; 下的配置应该填充文件target/jmeter/bin/user.properties。这没有发生,根本没有创建文件。

【问题讨论】:

    标签: maven jmeter jmeter-maven-plugin


    【解决方案1】:

    查看此常见问题解答:

    https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/FAQ

    将配置移到执行块之外应该可以解决您的问题:

    <profiles>
        <profile>
            <id>jmeter-test</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.lazerycode.jmeter</groupId>
                        <artifactId>jmeter-maven-plugin</artifactId>
                        <version>2.0.3</version>
                        <executions>
                            <execution>
                                <id>jmeter-tests</id>
                                <goals>
                                    <goal>jmeter</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <propertiesUser>
                                <threadCount>5</threadCount>
                                <environment>test</environment>
                            </propertiesUser>
                            <testResultsTimestamp>false</testResultsTimestamp>
                            <proxyConfig>
                                <host>localhost</host>
                                <port>8888</port>
                            </proxyConfig>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    

    【讨论】:

      猜你喜欢
      • 2012-10-03
      • 2011-11-25
      • 2015-09-24
      • 2017-01-28
      • 2013-09-05
      • 1970-01-01
      • 1970-01-01
      • 2014-01-28
      • 2011-04-11
      相关资源
      最近更新 更多