JMeter(三十三):maven项目构建之配置文件

时间:2024-10-09 08:24:31
  • <project xmlns="/POM/4.0.0" xmlns:xsi="http:///2001/XMLSchema-instance"
  • xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.">
  • <modelVersion>4.0.0</modelVersion>
  • <groupId></groupId>
  • <artifactId>maven2jmeter</artifactId>
  • <version>0.0.1-SNAPSHOT</version>
  • <packaging>jar</packaging>
  • <description>Check that report generation works</description>
  • <name>maven2jmeter</name>
  • <url>http://</url>
  • <properties>
  • <>UTF-8</>
  • <!-- env.引用jenkins变量使用,生成jmeter脚本报告 -->
  • <!-- ${}/Report/${env.BUILD_ID}/jtl ${}/Report/${env.BUILD_ID}/details
  • ${}/Report/${env.BUILD_ID}/summary -->
  • <>${}\jmeter\results</>
  • <>${}\jmeter\details</>
  • <>${}\jmeter\summary</>
  • <ReportName>TestReport</ReportName>
  • </properties>
  • <dependencies>
  • <dependency>
  • <groupId>junit</groupId>
  • <artifactId>junit</artifactId>
  • <version>4.12</version>
  • <scope>test</scope>
  • </dependency>
  • <dependency>
  • <groupId>mysql</groupId>
  • <artifactId>mysql-connector-java</artifactId>
  • <version>5.1.13</version>
  • </dependency>
  • <!--此处 添加自己引入的jar包 -->
  • </dependencies>
  • <pluginRepositories>
  • <pluginRepository>
  • <id>Codehaus repository</id>
  • <url>http:///</url>
  • <releases>
  • <enabled>true</enabled>
  • <updatePolicy>always</updatePolicy>
  • </releases>
  • <snapshots>
  • <enabled>true</enabled>
  • <updatePolicy>always</updatePolicy>
  • </snapshots>
  • </pluginRepository>
  • </pluginRepositories>
  • <build>
  • <plugins>
  • <plugin>
  • <!-- 核心插件,用来执行jmx脚本,注意版本号,jmeter版本越高插件的版本也要相应变高 -->
  • <groupId></groupId>
  • <artifactId>jmeter-maven-plugin</artifactId>
  • <version>2.5.1</version>
  • <configuration>
  • <!--报告文件尾部输出时间 -->
  • <!-- 默认报告优化,修改配置 -->
  • <propertiesJMeter>
  • <log_level.jmeter>DEBUG</log_level.jmeter>
  • </propertiesJMeter>
  • <resultsFileFormat>xml</resultsFileFormat>
  • <ignoreResultFailures>true</ignoreResultFailures>
  • <testResultsTimestamp>false</testResultsTimestamp>
  • <!-- 如果不想查看jmeter生成的log,设置为true -->
  • <suppressJMeterOutput>true</suppressJMeterOutput>
  • <!-- 增加扩展插件 -->
  • <jmeterExtensions>
  • <!--此处自己引入的jar包 -->
  • </jmeterExtensions>
  • <!-- 增加jar包,需要先将jar注册到本地maven仓库,打开cmd使用如下命令 -->
  • <!--mvn install:install-file -Dfile=D:\GIT\ZyzxAPIAutoTest\TXPTAPIAutoTest\plugns\
  • -DgroupId= -DartifactId=jmeter-plugins-json -Dversion=2.6
  • -Dpackaging=jar -->
  • <!-- <jmeterExtensions> -->
  • <!-- jmeter扩展插件 json path assert -->
  • <!-- <artifact>:jmeter-plugins-json:2.7</artifact> -->
  • <!-- 本地自己写的jar -->
  • <!-- <artifact>:smrz-utils:1.0</artifact> -->
  • <!-- </jmeterExtensions> -->
  • <!-- 设置jmeter生成结果文件格式 -->
  • <resultsFileFormat>xml</resultsFileFormat>
  • <!-- 设置忽略失败是否停止运行 -->
  • <ignoreResultFailures>true</ignoreResultFailures>
  • <!--设置结果是否有时间戳,与appendResultsTimestamp 或resultsFileNameDateFormat 搭配使用 -->
  • <testResultsTimestamp>false</testResultsTimestamp>
  • <testFilesIncluded>
  • <!-- 使用<jMeterTestFiles>选择执行用例 -->
  • <!-- <jMeterTestFile>*.jmx</jMeterTestFile> -->
  • <!-- 标签排除用例 -->
  • <excludeJMeterTestFile>*.jmx</excludeJMeterTestFile>
  • </testFilesIncluded>
  • <resultsDirectory>${}</resultsDirectory>
  • <!-- 使用<testFilesDirectory>指定测试用例的路径 -->
  • <!-- <testFilesDirectory>/scratch/testfiles/</testFilesDirectory> -->
  • </configuration>
  • <executions>
  • <execution>
  • <id>jmeter-tests</id>
  • <phase>verify</phase>
  • <!--脚本所在的文件夹 -->
  • <goals>
  • <goal>jmeter</goal>
  • </goals>
  • <configuration>
  • <appendResultsTimestamp>true</appendResultsTimestamp>
  • <skipTests>${skipTests}</skipTests>
  • </configuration>
  • </execution>
  • </executions>
  • </plugin>
  • <plugin>
  • <artifactId>maven-compiler-plugin</artifactId>
  • <configuration>
  • <source>1.8</source>
  • <target>1.8</target>
  • <encoding>UTF-8</encoding>
  • <compilerArguments>
  • <extdirs>target\jmeter\lib</extdirs>
  • </compilerArguments>
  • </configuration>
  • </plugin>
  • <!-- 解决报告展开收缩的图标问题 -->
  • <plugin>
  • <artifactId>maven-resources-plugin</artifactId>
  • <executions>
  • <execution>
  • <id>copy-resources</id>
  • <phase>compile</phase>
  • <goals>
  • <goal>copy-resources</goal>
  • </goals>
  • <configuration>
  • <outputDirectory>${}</outputDirectory>
  • <resources>
  • <resource>
  • <directory>${basedir}/src/test/resources/png</directory>
  • <filtering>true</filtering>
  • </resource>
  • </resources>
  • </configuration>
  • </execution>
  • </executions>
  • </plugin>
  • <plugin>
  • <!--根据xsl模版把jtl文件转换成html,官网地址: http:///xml-maven-plugin/examples/ -->
  • <groupId></groupId>
  • <artifactId>xml-maven-plugin</artifactId>
  • <version>1.0-beta-3</version>
  • <executions>
  • <execution>
  • <phase>verify</phase>
  • <goals>
  • <goal>transform</goal>
  • </goals>
  • </execution>
  • </executions>
  • <configuration>
  • <transformationSets>
  • <!-- 可以根据不同的模版,同时生成多个报告 -->
  • <transformationSet>
  • <dir>${}</dir>
  • <stylesheet>src\test\resources\jmeter-results-detail-report_21.xsl</stylesheet>
  • <outputDir>${}</outputDir>
  • <fileMappers>
  • <fileMapper
  • implementation="">
  • <targetExtension>html</targetExtension>
  • </fileMapper>
  • </fileMappers>
  • </transformationSet>
  • <transformationSet>
  • <dir>${}</dir>
  • <stylesheet>src\test\resources\</stylesheet>
  • <outputDir>${}</outputDir>
  • <!-- 把jtl格式转传承html -->
  • <fileMappers>
  • <fileMapper
  • implementation="">
  • <targetExtension>html</targetExtension>
  • </fileMapper>
  • </fileMappers>
  • </transformationSet>
  • </transformationSets>
  • </configuration>
  • <!-- using XSLT 2.0 解决时间为NAN -->
  • <dependencies>
  • <dependency>
  • <groupId></groupId>
  • <artifactId>saxon</artifactId>
  • <version>8.7</version>
  • </dependency>
  • </dependencies>
  • </plugin>
  • <plugin>
  • <groupId></groupId>
  • <artifactId>maven-dependency-plugin</artifactId>
  • <executions>
  • <execution>
  • <id>copy-dependencies</id>
  • <phase>prepare-package</phase>
  • <goals>
  • <goal>copy-dependencies</goal>
  • </goals>
  • <configuration>
  • <outputDirectory>${}/jmeter/lib</outputDirectory>
  • <overWriteReleases>false</overWriteReleases>
  • <overWriteSnapshots>false</overWriteSnapshots>
  • <overWriteIfNewer>true</overWriteIfNewer>
  • </configuration>
  • </execution>
  • </executions>
  • </plugin>
  • <plugin>
  • <groupId></groupId>
  • <artifactId>maven-jar-plugin</artifactId>
  • <configuration>
  • <archive>
  • <manifest>
  • <addClasspath>true</addClasspath>
  • <classpathPrefix>lib/</classpathPrefix>
  • <mainClass>theMainClass</mainClass>
  • </manifest>
  • </archive>
  • </configuration>
  • </plugin>
  • </plugins>
  • <defaultGoal>clean</defaultGoal>
  • </build>
  • </project>