无法使用带有 maven 的 HTTP Cookie 管理器运行 jmeter 脚本

发布于 2024-10-21 04:16:19 字数 6240 浏览 1 评论 0原文

最近我正在研究自动化测试。目标是获得更快的反馈,因此我们决定使用 maven-jmeter-plugin、jmeter 脚本和 Hudson。

我已经编写了一些示例 jmeter 脚本模板,它们工作正常(只是用于访问页面的快速冒烟测试)。

问题是我必须完成的脚本需要“HTTP Cookie Menager”才能正确运行。

这是我目前正在使用的虚拟脚本,试图找出问题所在。

Test Plan
 |-> Thread Group
      |-> HTTP Cookie Menager
      |-> Loop Controler
          |-> HTTP request 

我使用与我准备的其他工作示例中相同的配置(jmeter.properties、update.properties、system.properties - 在最后一个文件中,我保留脚本使用的值,如用户数、循环计数、主机等)。

当我使用 mvn clean verify 运行它时,它会返回以下输出:

mvn -e clean verify
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
        Profile with id: 'development,hudson' has not been activated.

[INFO] ------------------------------------------------------------------------
[INFO] Building com.cybercom.test::peformance-test-mvn
[INFO]    task-segment: [clean, verify]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\Hudson\data\jobs\peformance-test-mvn\workspace\trunk\target
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [jmeter:jmeter {execution: jmeter-tests}]
[INFO] Executing test: C:\Hudson\data\jobs\peformance-test-mvn\workspace\trunk\src\test\jmeter\temp.jmx
Error in NonGUIDriver java.lang.NullPointerException
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There were test errors
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: There were test errors
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:55
6)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.jav
a:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoFailureException: There were test errors
        at org.apache.jmeter.JMeterMojo.checkForErrors(JMeterMojo.java:115)
        at org.apache.jmeter.JMeterMojo.execute(JMeterMojo.java:102)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        ... 17 more

没有 HTTP Cookie Menager 的相同脚本运行得很好,但正如我提到的,这只是用于调查错误的虚拟脚本。

我认为 pom 文件在这里也可能有用:

<?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>test</groupId>
    <artifactId>peformance-test-mvn</artifactId>
    <name>${groupId}::${artifactId}</name>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.jmeter</groupId>
                <artifactId>maven-jmeter-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <reportDir>target/jmeter-reports</reportDir>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <pluginRepositories>
        <pluginRepository>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <id>nexus</id>
            <url>XXXX</url>
            <name>YYYY</name>
            <layout>default</layout>
        </pluginRepository>
    </pluginRepositories>
</project>

我缺少什么?

提前致谢 帕维尔

Recently I'm working with test automation. The goal is to get quicker feedback so we decided to use maven-jmeter-plugin, jmeter scripts and Hudson.

I have wrote some example jmeter scripts templates and they are working fine (just a quick smoke test for accessing pages).

The problem is that script I have to complete requires 'HTTP Cookie Menager' to run correctly.

Here is dummy script I'm using at the moment trying identify what is wrong.

Test Plan
 |-> Thread Group
      |-> HTTP Cookie Menager
      |-> Loop Controler
          |-> HTTP request 

I use the same configuration as in other working examples I have prepared (jmeter.properties, update.properties, system.properties - in the last file I keep values used by script like number of users, loop count, host, etc).

When I run it with mvn clean verify it returns following output:

mvn -e clean verify
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
        Profile with id: 'development,hudson' has not been activated.

[INFO] ------------------------------------------------------------------------
[INFO] Building com.cybercom.test::peformance-test-mvn
[INFO]    task-segment: [clean, verify]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\Hudson\data\jobs\peformance-test-mvn\workspace\trunk\target
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [jmeter:jmeter {execution: jmeter-tests}]
[INFO] Executing test: C:\Hudson\data\jobs\peformance-test-mvn\workspace\trunk\src\test\jmeter\temp.jmx
Error in NonGUIDriver java.lang.NullPointerException
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There were test errors
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: There were test errors
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:55
6)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.jav
a:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoFailureException: There were test errors
        at org.apache.jmeter.JMeterMojo.checkForErrors(JMeterMojo.java:115)
        at org.apache.jmeter.JMeterMojo.execute(JMeterMojo.java:102)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        ... 17 more

The same script without HTTP Cookie Menager works perfectly well, but as I mentioned this is just dummy script to investigate what is wrong.

I assume that pom file might be useful as well here it is:

<?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>test</groupId>
    <artifactId>peformance-test-mvn</artifactId>
    <name>${groupId}::${artifactId}</name>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.jmeter</groupId>
                <artifactId>maven-jmeter-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <reportDir>target/jmeter-reports</reportDir>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <pluginRepositories>
        <pluginRepository>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <id>nexus</id>
            <url>XXXX</url>
            <name>YYYY</name>
            <layout>default</layout>
        </pluginRepository>
    </pluginRepositories>
</project>

What am I missing??

Thanks in advance
Pawel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

客…行舟 2024-10-28 04:16:19

问题解决了。

maven-jmeter-plugin-1.0.pom 中缺少 commons-logging 依赖项

添加以下行

<dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>1.1.1</version>
</dependency>

解决了问题。

Problem solved.

commons-logging dependency was missing in maven-jmeter-plugin-1.0.pom

Adding following lines

<dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>1.1.1</version>
</dependency>

Solved problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文