我的POM.xml是
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.idea.perf.test</groupId>
<artifactId>jmeter-perf-tests</artifactId>
<version>4.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>jmeter-perf-tests</name>
<properties>
<jmeterScriptFile>Jmeter-Gemini-UI-RatePlanReport.jmx</jmeterScriptFile>
<jmeterThreads>2</jmeterThreads>
<jmeterRampUpTime>1</jmeterRampUpTime>
<jmeterLoopCount>1</jmeterLoopCount>
<Port>443</Port>
<UrlProtocol>https</UrlProtocol>
<UrlDomainName>stageg.com</urlDomainName>
<PropertyList>..\..\..\src\test\properties\GeminiStressboxUI.csv</PropertyList>
<BinaryDir>..\..\..\src\test\binaries</BinaryDir>
<jmeterRunScriptFor>RPtHomePage,SelectRCRange,SelectDateRange,SelectMultiPropertyGroups</jmeterRunScriptFor>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.adobe.blazeds</groupId>
<artifactId>blazeds-common</artifactId>
<version>3.2.0.3978</version>
</dependency>
<dependency>
<groupId>com.adobe.blazeds</groupId>
<artifactId>blazeds-core</artifactId>
<version>3.2.0.3978</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>a</artifactId>
<version>1.2</version>
<classifier>id</classifier>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>blazemeter</artifactId>
<version>1.2</version>
<classifier/>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>a_newAmfProxyConverter</artifactId>
<version>1.2</version>
<classifier/>
</dependency>
<dependency>
<groupId>serializeFlex</groupId>
<artifactId>org.racso.jmeter</artifactId>
<version>0.0.1</version>
<classifier/>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>amf_custom_plugin</artifactId>
<version>1.0</version>
<classifier>idea</classifier>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>b</artifactId>
<version>1.2</version>
<classifier/>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-assets</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/../jmeter/lib/ext</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>org.apache.jmeter</groupId>
<artifactId>JMeter-AMF</artifactId>
</artifactItem>
<artifactItem>
<groupId>com.adobe.blazeds</groupId>
<artifactId>blazeds-common</artifactId>
</artifactItem>
<artifactItem>
<groupId>com.adobe.blazeds</groupId>
<artifactId>blazeds-core</artifactId>
</artifactItem>
<artifactItem>
<groupId>org.apache.jmeter</groupId>
<artifactId>a</artifactId>
<classifier>idea</classifier>
</artifactItem>
<artifactItem>
<groupId>org.apache.jmeter</groupId>
<artifactId>a_newAmfProxyConverter</artifactId>
<classifier/>
</artifactItem>
<artifactItem>
<groupId>org.apache.jmeter</groupId>
<artifactId>blazemeter</artifactId>
<classifier/>
</artifactItem>
<artifactItem>
<groupId>serializeFlex</groupId>
<artifactId>org.racso.jmeter</artifactId>
<classifier/>
</artifactItem>
<artifactItem>
<groupId>org.apache.jmeter</groupId>
<artifactId>b</artifactId>
<classifier/>
</artifactItem>
<artifactItem>
<groupId>org.apache.jmeter</groupId>
<artifactId>amf_custom_plugin</artifactId>
<classifier>idea</classifier>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- Execute JMeter Script-->
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<configuration>
<suppressJMeterOutput>false</suppressJMeterOutput>
<overrideRootLogLevel>debug</overrideRootLogLevel>
<jmeterLogLevel>DEBUG</jmeterLogLevel>
<testFilesIncluded>
<testFilesIncluded>${jmeterScriptFile}</testFilesIncluded>
</testFilesIncluded>
<jMeterProcessJVMSettings>
<xms>4096</xms>
<xmx>4096</xmx>
<arguments>
<argument>-Xprof</argument>
<argument>-Xfuture</argument>
</arguments>
</jMeterProcessJVMSettings>
<propertiesUser>
<jmeterThreads>${jmeterThreads}</jmeterThreads>
<jmeterRampUpTime>${jmeterRampUpTime}</jmeterRampUpTime>
<jmeterLoopCount>${jmeterLoopCount}</jmeterLoopCount>
<UrlProtocol>${UrlProtocol}</UrlProtocol>
<Port>${Port}</Port>
<UrlDomainName>${rlDomainName}</UrlDomainName>
<PropertyList>${PropertyList}</PropertyList>
<BinaryDir>${BinaryDir}</BinaryDir>
<jmeterRunScript>${jmeterRunScript}</jmeterRunScript>
</propertiesUser>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Execute JMeter Reports-->
<!--<plugin>-->
<!--<groupId>com.lazerycode.jmeter</groupId>-->
<!--<artifactId>jmeter-analysis-maven-plugin</artifactId>-->
<!--<version>1.0.0</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<goals>-->
<!--<goal>analyze</goal>-->
<!--</goals>-->
<!--<phase>post-integration-test</phase>-->
<!--<configuration>-->
<!--<source>${project.build.directory}/jmeter/results/*</source>-->
<!--<targetDirectory>${project.build.directory}/reports</targetDirectory>-->
<!--<generateCSVs>true</generateCSVs>-->
<!--<generateCharts>true</generateCharts>-->
<!--</configuration>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
</plugins>
</build>
</project>
您能建议我将文件放在哪里以及如何将文件中的值读入JMeter吗?
例如:
<jmeterThreads>${jmeterThreads}</jmeterThreads>
<-如何在JMeter脚本中使用此变量?
我想使用的其他变量是:
<jmeterRampUpTime>${jmeterRampUpTime}</jmeterRampUpTime>
<jmeterLoopCount>${jmeterLoopCount}</jmeterLoopCount>
答案 0 :(得分:1)
假设您定义以下块:
<properties>
<jmeterThreads>1</jmeterThreads>
</properties>
您应该能够在JMeter Maven Plugin声明中添加以下部分:
<configuration>
<propertiesUser>
<jmeterThreads>${jmeterThreads}</jmeterThreads>
</propertiesUser>
</configuration>
,并在需要的情况下,在您的JMeter测试中使用__P() function引用值:
${__P(jmeterThreads)}
此外,您可以使用-D命令行参数修改值,例如:
mvn -DjmeterThreads=100 clean verify
其他属性应该以相同的方式处理。
参考文献:
完整的 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>org.apache</groupId>
<artifactId>jmeter-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<jmeterThreads>1</jmeterThreads>
</properties>
<build>
<plugins>
<plugin>
<configuration>
<propertiesUser>
<jmeterThreads>${jmeterThreads}</jmeterThreads>
</propertiesUser>
</configuration>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.8.1</version>
<executions>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
答案 1 :(得分:1)