最近我正在使用测试自动化。目标是获得更快的反馈,因此我们决定使用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运行它时,验证它返回以下输出:
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>
我错过了什么?
提前致谢 的Pawel
答案 0 :(得分:1)
问题解决了。
maven-jmeter-plugin-1.0.pom 中缺少commons-logging依赖项
添加以下行
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
解决了问题。