在POM.xml文件中,我设置了以下变量,并使用以下命令从maven运行jmeter脚本。但这是行不通的。表示线程未与10个用户一起运行。你能帮我这个忙吗? 另外,在JMeter,我需要设置什么? Maven命令: mvn -DJmeterTestFile = ER_SampleTest -DRampUp = 2 -DLoopcount = 1 -DThreadcount = 10验证
我的POM.xml如下
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter-demo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jmeter-demo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>9.1.1.v20140108</version>
<classifier>hybrid</classifier>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter</artifactId>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_http</artifactId>
<version>2.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<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>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<!-- This configuraition is to specify jmeter script, number -->
<testFilesIncluded>
<jMeterTestFile>${JmeterTestFile}.jmx</jMeterTestFile>
</testFilesIncluded>
<testResultsTimestamp>false</testResultsTimestamp>
<propertiesUser>
<Threadcount>${Threadcount}</Threadcount>
<Loopcount>${Loopcount}</Loopcount>
<Rampup>${RampUp}</Rampup>
</propertiesUser>
<testPlanLibraries>
<artifact>org.apache.activemq:activemq-spring:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-client:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-broker:5.15.2</artifact>
</testPlanLibraries>
<excludedArtifacts>
<exclusion>commons-pool2:commons-pool2</exclusion>
<exclusion>commons-math3:commons-math3</exclusion>
<exclusion>org.slf4j:slf4j-nop</exclusion>
<exclusion>logkit:logkit</exclusion>
<exclusion>avalon-logkit:avalon-logkit</exclusion>
<exclusion>jdom:jdom</exclusion>
<exclusion>log4j:log4j</exclusion>
<exclusion>commons-logging:commons-logging</exclusion>
<exclusion>excalibur-logger:excalibur-logger</exclusion>
</excludedArtifacts>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-casutg:2.4</artifact>
</jmeterExtensions>
<downloadExtensionDependencies>false</downloadExtensionDependencies>
<excludes>
<exclude>**/JMeter/plugins/functional/controler/**/*</exclude>
<exclude>**/JMeter/plugins/controler/websocketapp/**</exclude>
</excludes>
<junitLibraries>
<artifact>com.lazerycode.junit:junit-test:1.0.0</artifact>
</junitLibraries>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
答案 0 :(得分:0)
您正在将JMeter属性-DRampUp=2 -DLoopcount=1 -DThreadcount=10
发送到您的jmx文件,
所以您必须在线程组中使用它们:
答案 1 :(得分:0)
您需要在JmeterTestFile
部分中定义Threadcount
,<properties>
等属性,例如:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<JmeterTestFile>test</JmeterTestFile>
<Threadcount>10</Threadcount>
<Loopcount>5</Loopcount>
<RampUp>1</RampUp>
</properties>
<configuration>
部分从maven-jar-plugin
移到jmeter-maven-plugin
${__P(Threadcount,)}
一样引用属性。 示例 pom.xml 文件(您可能仍需要对其进行修改,因为我不知道除了运行JMeter测试外它还应该做什么)
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter-demo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jmeter-demo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>9.1.1.v20140108</version>
<classifier>hybrid</classifier>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_http</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<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>
<configuration>
<!-- This configuraition is to specify jmeter script, number -->
<testFilesIncluded>
<jMeterTestFile>${JmeterTestFile}.jmx</jMeterTestFile>
</testFilesIncluded>
<testResultsTimestamp>false</testResultsTimestamp>
<propertiesUser>
<Threadcount>${Threadcount}</Threadcount>
<Loopcount>${Loopcount}</Loopcount>
<Rampup>${RampUp}</Rampup>
</propertiesUser>
<testPlanLibraries>
<artifact>org.apache.activemq:activemq-spring:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-client:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-broker:5.15.2</artifact>
</testPlanLibraries>
<excludedArtifacts>
<exclusion>commons-pool2:commons-pool2</exclusion>
<exclusion>commons-math3:commons-math3</exclusion>
<exclusion>org.slf4j:slf4j-nop</exclusion>
<exclusion>logkit:logkit</exclusion>
<exclusion>avalon-logkit:avalon-logkit</exclusion>
<exclusion>jdom:jdom</exclusion>
<exclusion>log4j:log4j</exclusion>
<exclusion>commons-logging:commons-logging</exclusion>
<exclusion>excalibur-logger:excalibur-logger</exclusion>
</excludedArtifacts>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-casutg:2.4</artifact>
</jmeterExtensions>
<downloadExtensionDependencies>false</downloadExtensionDependencies>
<junitLibraries>
<artifact>com.lazerycode.junit:junit-test:1.0.0</artifact>
</junitLibraries>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<JmeterTestFile>test</JmeterTestFile>
<Threadcount>10</Threadcount>
<Loopcount>5</Loopcount>
<RampUp>1</RampUp>
</properties>
</project>