Jmeter+Maven自动化测试,并生成Html报告

利用Jmeter编写测试用例

导出Jmeter测试文件 *.jmx

并放入/src/test/jmeter目录中

编写Maven 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.ubikloadpack.jmeter</groupId>
<artifactId>maven-generate-reports</artifactId>
<version>1.0.0</version>
<description>Check that report generation works</description>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
    <plugins>
        <plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>2.2.0</version>
            <configuration>
                <suppressJMeterOutput>false</suppressJMeterOutput>
                <testFilesIncluded>
                    <testFilesIncluded>**/*.jmx</testFilesIncluded>
                </testFilesIncluded>
                <generateReports>true</generateReports>
            </configuration>
            <executions>
                <execution>
                    <id>configure</id>
                    <goals>
                        <goal>configure</goal>
                    </goals>
                </execution>
                <execution>
                    <id>performance test</id>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
                <execution>
                    <id>verify</id>
                    <goals>
                        <goal>results</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

运行mvn verify

在target目录就会产生

其中,
reports为html报告
results为csv报告

posted @ 2018-03-20 20:09  CHENV  阅读(2651)  评论(1编辑  收藏  举报