Jmeter: Test plan has two thread groups but it generated only 1 jtl report

一世执手 提交于 2019-12-20 06:43:14

问题


My Jmeter Test Plan has two threads. Both threads requires separate CSV (csv parameterization) files.

At the end of test mvn verify I expect two .jtl files generated, but get only one. Seems only 1 thread is running. When I run in GUI then it works fine, without maven.

Test Plan:

POM.xml

<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.demo.performancetesting</groupId>
    <artifactId>demo-performance-testing</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.1.0</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>de.codecentric</groupId>
                <artifactId>jmeter-graph-maven-plugin</artifactId>
                <version>0.1.0</version>
                <configuration>
                    <inputFile>${project.build.directory}/jmeter/results/*.jtl</inputFile>
                    <graphs>
                        <graph>
                            <pluginType>ResponseTimesOverTime</pluginType>
                            <width>800</width>
                            <height>600</height>
                            <outputFile>${project.build.directory}/jmeter/results/BlazeDemoRequest.png</outputFile>
                        </graph>
                    </graphs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I have already gone through these posts but no luck:

Can we run two thread groups parallely in a single test plan in Jmeter?

Why only 2 out 3 JMeter Thread group execute?

I am using Windows 7, Maven 3, Jmeter Maven Plugin


回答1:


You will have 2 .jtl files generated only in 2 cases:

  1. You have 2 .jmx scripts under src/test/jmeter folder
  2. You enable Aggregate Report listeners and configure them to save results to ../results folder prefixed by the test name or __threadGroupName() (the function is available since JMeter 5.0)

In general in case of any unexpected behaviour of your JMeter test get used to look at jmeter.log file, in case of JMeter tests execution via Maven plugin the log file(s) is(are) located under target/jmeter/logs folder relative to your main pom.xml file. Normally it should contain enough troubleshooting information to get to the bottom of the issue. The most common reason for JMeter test or thread groups not being executed are:

  • incorrect number of threads provided (i.e. failing parameterization)
  • dependency file is missing (i.e. CSV file is not being present in expected location)



回答2:


You can disable all listeners while running tests as it is recommended.

  1. And just add a "Simple Data Writer" listener and give location to save the results. Recommended is with file name with .jtl file type.
  2. if you want 2 .jtl files you can add this listener in each thread group. If you want aggregate results then add this listener at test plan level.
  3. Once test run is completed you can browse this .jtl file into any desired listener you want, it works just fine.



回答3:


why do you expect 2 generated jtl files since you don’t have any listener.

In this case in non gui mode, jmeter would generate only 1 file, this is what the jmeter-maven-plugin does.

by the way, you’re using an old version 2.1.0 of the plugin, last one is 2.7.0.




回答4:


While debugging my issue I found that 2nd thread was not even working in GUI mode also. Then I switched the .csv files from Thread 1 to 2, found that only 1 .csv file always work. Finally, after further digging I found that in order to run your .csv in need to be in src/test/jmeter/testdata folder and not inside apache-jmeter-3.2/bin/testdata.

Answer: Second thread was not working because it was using incorrect .csv. To find it out click on yellow triangle on top right hand corner in Jmeter GUI. It toggles logs display. Those logs showed me error that .csv was not found.

Yes I have also come across few online forums who would tell you to put .csv inside apache-jmeter-3.2\bin\testdata so that path remain relative i.e. not dependent to project structure or OS. This is CSV parameterization in Jmeter.

So, I would suggest try both, for me it worked inside src/test/jmeter/testdata not Jmeter bin folder.



来源:https://stackoverflow.com/questions/52575057/jmeter-test-plan-has-two-thread-groups-but-it-generated-only-1-jtl-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!