使用MAven执行JMETER Junit采样器(Selenium Webdriver)

使用MAven执行JMETER Junit采样器(Selenium Webdriver),jmeter,Jmeter,我创建了一个简单的JMETER负载测试,它在JMETER中运行得非常好。我通过以下方式创建了负载测试用例: 在eclipse中编写简单的JUNIT测试 将JUNIT测试导出为Jar 使用JUNIT测试用例创建负载测试 上述方法在JMETER内运行良好。但是,我无法使用MAVEN(JMETER MAVEN插件)运行相同的测试,即测试不运行。我能看到一条消息 [info] Executing test: JUnitRequest.jmx [info] Completed Test: JUnitR

我创建了一个简单的JMETER负载测试,它在JMETER中运行得非常好。我通过以下方式创建了负载测试用例:

  • 在eclipse中编写简单的JUNIT测试
  • 将JUNIT测试导出为Jar
  • 使用JUNIT测试用例创建负载测试
上述方法在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] 
然后显示一条错误消息:

请在下面找到my 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>

4.0.0
com.jmeter.restapi
餐馆
1.0-快照
com.lazerycode.jmeter
jmetermaven插件
1.9.1
jmeter测试
验证
性能测试
kg.apc:jmeter插件:pom:1.3.1
junit:junit测试:1.0.0
mysql
mysql连接器java
5.1.17
罐子
编译

接下来,请您将错误以及我们最感兴趣的内容包括在内,而不是您的配置

关于你的问题本身,我没有看到任何迹象表明你的jar或依赖库被堵塞了

您需要包括:

  • 你的JUnit罐本身
  • 任何依赖项
  • 输入pom.xml文件。wiki的第页详细描述了该过程

    我的期望是,您的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>
    
    
    4.0.0
    jmeter硒junit
    
    文章中提供了更多关于运行JMeter测试的不同方法的信息,包括Maven插件

    非常感谢Dmitri T。我也尝试了Maven antrun插件,即使它看起来也很好用。