jmeter-maven-plugin
Posted 此生不换Yang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jmeter-maven-plugin相关的知识,希望对你有一定的参考价值。
Maven编译JMeter,
使用的是jmeter-maven-plugin插件:
<?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>shanghai</groupId>
<artifactId>jmeter_blog</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmeter.result.jtl.dir>${project.build.directory}/jmeter/results</jmeter.result.jtl.dir>
<jmeter.result.html.dir>${project.build.directory}/jmeter/html</jmeter.result.html.dir>
<ReportName>TestReport</ReportName>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactId>mysql-connector-java</artifactId>
<outputDirectory>${project.build.directory}/jmeter/lib</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<resultsFileFormat>xml</resultsFileFormat>
<ignoreResultFailures>true</ignoreResultFailures>
<testResultsTimestamp>false</testResultsTimestamp>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jmeter/html</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>${jmeter.result.jtl.dir}</dir>
<stylesheet>src/main/resources/jmeter-results-detail-report_21.xsl</stylesheet>
<outputDir>${jmeter.result.html.dir}</outputDir>
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
<version>8.7</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
整个工程的目录结构:
执行命令mvn verify
测试报告的路径:
测试报告的内容:
以上是关于jmeter-maven-plugin的主要内容,如果未能解决你的问题,请参考以下文章
Jmeter-Maven-Plugin高级应用:Log Levels
Jmeter-Maven-Plugin高级应用:Modifying Properties
Jmeter-Maven-Plugin高级应用:Proxy Configuration
Jmeter-Maven-Plugin高级应用:Remote Server Configuration
使用Jmeter-Maven-Plugin搭建基于jmeter+Jenkins的性能测试平台
Jmeter-Maven-Plugin高级应用:Configuring the jvm that the jmeter process runs in