且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有Maven的Jmeter以及使用Groovy导入使用外部Groovy脚本的问题

更新时间:2023-12-05 14:31:04

我找到了答案:

  • 我需要将要在测试中使用的库打包到jar中,然后将其放入jmeter/lib目录
  • 我必须对齐Sampler脚本路径,以便jmeter可以使用它们

第一个解决方案是

The solution for the first is the following from jmeter-maven-plugin doc:

<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>USE LAST VERSION</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <testPlanLibraries>
                             <artifact>org.apache.activemq:activemq-spring:5.15.2</artifact>
                 <artifact>org.apache.activemq:activemq-client:5.15.2</artifact>
                 <artifact>org.apache.activemq:activemq-broker:5.15.2</artifact>
                </testPlanLibraries>
                        <excludedArtifacts>
                             <exclusion>com.sun.jdmk:jmxtools</exclusion>
                             <exclusion>com.sun.jmx:jmxri</exclusion>
            </excludedArtifacts>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>

第二个解决方案是,我需要复制jmx文件旁边的Sampler脚本. Maven可以使用 maven-resource-plugin 轻松地做到这一点.

The solution for the second is that I need to copy Sampler scripts next to jmx file. Maven can do this easily using maven-resource-plugin.