我创建了一个简单的JMETER Load测试,它可以从JMETER中完美运行。我通过以下方式创建了Load测试用例:
以上在JMETER中工作正常。但是,我无法使用MAVEN(JMETER MAVEN插件)运行相同的操作,即测试不运行。我可以看到一条消息
[info] Executing test: JUnitRequest.jmx
[info] Completed Test: JUnitRequest.jmx
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.033s
[INFO] Finished at: Wed Jun 07 20:12:40 BST 2017
[INFO] Final Memory: 16M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:1.9.1:jmeter (jmeter-tests) on project restapitest: C:\2017\JMETER\RestApiTest\target\jmeter\results\20170607-JUnitRequest.jtl (The system cannot find the file specified) -> [Help 1]
[ERROR]
然后出现错误消息:
请在下面找到我的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.jmeter.restapi</groupId>
<artifactId>restapitest</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins:pom:1.3.1</artifact>
</jmeterExtensions>
<junitLibraries>
<artifact>com.lazerycode.junit:junit-test:1.0.0</artifact>
</junitLibraries>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.17</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:0)
前进可以请您包含错误以及我们最感兴趣的错误,而不是您的配置。
关于你的问题本身,我没有看到任何插入你的jar或依赖库的迹象。
您需要包含:
进入 pom.xml 文件。 Adding additional libraries to the classpath wiki的JMeter Maven Plugin页面详细介绍了该过程。
我的期望是你的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>jmeter-selenium-junit</groupId>
<artifactId>jmeter-selenium-junit-test</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>your-junit-jar</id>
<name>your junit repo</name>
<url>file:/path/to/your-junit-jar.jar</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<jmeterExtensions>
<artifact>org.seleniumhq.selenium:selenium-java:2.52.0</artifact>
<artifact>org.seleniumhq.selenium:selenium-firefox-driver:2.52.0</artifact>
</jmeterExtensions>
<junitLibraries>
<artifact>com.yourcompany.yourgroup:your-artifact:1.0-SNAPSHOT</artifact>
</junitLibraries>
</configuration>
</plugin>
</plugins>
</build>
</project>
有关运行JMeter测试(包括Maven插件)的不同方法的更多信息,请参阅Five Ways To Launch a JMeter Test without Using the JMeter GUI文章