1

我对 maven 和 jmeter 使用 jmeter-maven-plugin 在 jmeter 中,我有一些断言失败,但是为什么 maven 项目也标记为成功?谁来帮帮我。坦克!

这是我的 Maven 项目 pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>1.10.1</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                        <configuration>
                            <overrideRootLogLevel>debug</overrideRootLogLevel>

                            <testFilesIncluded>
                                <jMeterTestFile>${includedTestFiles}</jMeterTestFile>
                            </testFilesIncluded>
                            <testFilesExcluded>
                                <excludeJMeterTestFile>${excluedTestFiles}</excludeJMeterTestFile>
                            </testFilesExcluded>
                            <jmeterPlugins>
                                <plugin>
                                    <groupId>kg.apc</groupId>
                                    <artifactId>jmeter-plugins-standard</artifactId>
                                </plugin>
                            </jmeterPlugins>

                            <propertiesJMeter>
                                <dateQueryValueS>${dateQueryValueS}</dateQueryValueS>>
                            </propertiesJMeter>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>kg.apc</groupId>
                        <artifactId>jmeter-plugins-standard</artifactId>
                        <version>1.3.1</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

这是构建

mvn verify -DincludedTestFiles=*unshipOrder.jmx -DexcluedTestFiles=noneOfExclued -DdateQueryValueS="2016-04-28 09:09:53"

[INFO]
[INFO] -------------------------------------------------------
[INFO]  P E R F O R M A N C E    T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO]
[info]
[debug] JMeter is called with the following command line arguments: -n -t E:\study\jmeter\src\test\jmeter\xbn-online-unshipOrder.jmx -l E:\study\jmeter\target\jmeter\results\20160513-xbn-online-unshipOrder.jtl -d E:\study\jmeter\target\jmeter -L DEBUG -j E:\study\jmeter\target\jmeter\logs\xbn-online-unshipOrder.jmx.log
[info] Executing test: xbn-online-unshipOrder.jmx
[debug] Creating summariser <summary>
[debug] Created the tree successfully using E:\study\jmeter\src\test\jmeter\xbn-online-unshipOrder.jmx
[debug] Starting the test @ Fri May 13 10:20:31 CST 2016 (1463106031631)
[debug] Waiting for possible shutdown message on port 4445
[debug] summary +      1 in     1s =    1.9/s Avg:   370 Min:   370 Max:   370 Err:     0 (0.00%) Active: 1 Started: 1 Finished: 0
[debug] summary +      1 in   0.1s =   10.4/s Avg:    64 Min:    64 Max:    64 Err:     1 (100.00%) Active: 0 Started: 1 Finished: 1
[debug] summary =      2 in     1s =    3.2/s Avg:   217 Min:    64 Max:   370 Err:     1 (50.00%)
[debug] Tidying up ...    @ Fri May 13 10:20:32 CST 2016 (1463106032341)
[debug] ... end of run
[info] Completed Test: xbn-online-unshipOrder.jmx
[INFO]
[INFO] Test Results:
[INFO]
[INFO] Tests Run: 1, Failures: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.629 s
[INFO] Finished at: 2016-05-13T10:20:32+08:00
[INFO] Final Memory: 22M/223M
[INFO] ------------------------------------------------------------------------
4

4 回答 4

1

如果你使用 2.6.0 版本的 plugin 或 upper ,你只需要设置这个:

<executions>
   <execution>
      <id>performance test</id>
     <goals><goal>jmeter</goal></goals>
   </execution>
   <execution>
       <id>verify</id>
       <goals><goal>results</goal></goals>
   </execution>
</executions>
于 2017-12-01T22:42:40.670 回答
1

我认为这就是 Maven 的工作方式。

此处:Maven 通过其生命周期执行项目。这样做时,它会执行 pom.xml 中定义/配置的插件(有效 POM 上的所有内容(以 Eclipse 术语))。

所以这里的“jmeter-maven-plugin”是在这个过程中执行的一个执行器。该插件完成其工作并提供结果。

maven 也以 SUCCESS note 完成其工作。因为从 Mavens 角度构建是成功的。

(如果您运行 JUnit/TestNG 测试套件,这将是类似的)这取决于我们找到一种方法(工具)以一种可呈现的方式解释生成的结果。

试试下面:

于 2016-12-13T23:57:22.420 回答
0

实际上,默认情况下它应该是失败的,如果没有看到你的测试计划和日志文件,很难说什么是错的。正在使用什么断言以及它是如何配置的?

同时,您可以尝试通过在部分中添加以下行来解决它<configuration>

<ignoreResultFailures>false</ignoreResultFailures>

参考:

于 2016-05-13T03:45:58.970 回答
0

您需要将此配置添加到<configuration>标记 内的 POM 文件中<scanResultsForFailedRequests>true</scanResultsForFailedRequests> <ignoreResultFailures>false</ignoreResultFailures>

也尝试从<configuration>标签中取出<executions>标签

最后执行块应该是这样的

<executions>
  <execution>
    <id>configure</id>
    <goals>
      <goal>configure</goal>
     </goals>
  </execution>
  <execution>
    <id>performance test</id>
    <goals>
      <goal>jmeter</goal>
    </goals>
  </execution>
  <execution>
    <id>verify</id>
    <goals>
      <goal>results</goal>
    </goals>
  </execution>
</executions>
于 2017-10-30T18:04:38.390 回答