在maven项目的pom.xml文件中添加
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
eclipse中右键项目->run as->maven build,Goals一栏填写clean install
构建完毕,会自动在target目录下生成jmeter文件夹并下载jmeter-maven-plugin插件
在项目的src->test目录下新建jmeter文件夹,并将用jmeter写好的jmx脚本放入其中
再次maven build,自动执行src/test/jmeter目录下的测试脚本,于target/jmeter/results(report)生成报告
注:
maven build时报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile)
解决办法:菜单栏选择windows->preferences->Java->Install JREs,添加一个jdk目录,不要选择jre目录,maven的一些功能需要使用jdk