首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MAven执行JMETER采样器(Selenium )

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

Stack Overflow用户
提问于 2017-06-07 19:28:01
回答 1查看 760关注 0票数 0

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

  • 在eclipse中编写一个简单的JUNIT测试
  • 将JUNIT测试导出为Jar
  • 使用JUNIT测试用例创建负载测试。

以上内容在JMETER内部运行良好。但是,我无法使用MAVEN ( JMETER插件)运行相同的程序,即测试不运行。我能看到一个留言

代码语言:javascript
复制
[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下面找到:

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-08 05:26:00

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

关于您的问题本身,我没有看到任何插入jar或依赖库的迹象。

你需要包括:

  1. JUnit jar本身
  2. 任何依赖项

进入pom.xml文件。这个过程在向类路径中添加其他库 wiki的JMeter Maven插件页面上有详细的描述。

我的期望是,您的pom.xml文件应该看起来像:

代码语言:javascript
复制
<?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>

有关运行包括Maven插件在内的不使用JMeter GUI启动JMeter测试的五种方法测试的不同方法的更多信息,请参见不使用JMeter GUI启动JMeter测试的五种方法文章

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44421272

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档