我收到错误 "Error generating the report: java.lang.NullPointerException" 而 运行 使用 JMeter-Maven 插件的 JMeter 脚本

I am getting an error "Error generating the report: java.lang.NullPointerException" while running the JMeter script using JMeter-Maven plugin

当 运行 使用 JMeter-Maven 插件的 JMeter 脚本时,我收到错误 "Error generating the report: java.lang.NullPointerException"。

下面是我收到的错误的屏幕截图:

下面是我的pom.xml文件:

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.branch.performance 简化访问 0.0.1-快照

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!--Access Portal Login page URL -->
    <AccessLoginPageURL>test-login.com</AccessLoginPageURL>
    <!-- base URL -->
    <BaseURL>test.branch.com</BaseURL>
    <!-- Number of users to simulate to execute the performance test plan -->
    <numberOfUsers>3</numberOfUsers>
    <!-- Time in seconds to get all users activated -->
    <rampupTimeInSeconds>1</rampupTimeInSeconds>
    <!-- Number of times the plan executed by every user -->
    <numberOfLoops>1</numberOfLoops>
    <apdexSatisfiedThreshold>2000</apdexSatisfiedThreshold>
    <apdexToleratedThreshold>4000</apdexToleratedThreshold>
    <!-- JMeter Dashboard output file report name -->
    <jmeterReportTitle>Performance Dashboard</jmeterReportTitle>
</properties>


<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>3.0.0</version>


            <executions>
                <execution>
                    <id>configuration</id>
                    <goals>
                        <goal>configure</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jmeter-tests</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jmeter-check-results</id>
                    <goals>
                        <goal>results</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                    <junitLibraries>
                        <artifact>mysql:mysql-connector-java:8.0.18</artifact>
                    </junitLibraries>
                <testFilesIncluded>

                    <jMeterTestFile>MyTestFile.jmx</jMeterTestFile>
                </testFilesIncluded>
                <testResultsTimestamp>false</testResultsTimestamp>
                <propertiesUser>
                    <AccessLoginPageURL>${LoginPageURL}</AccessLoginPageURL>
                    <BaseURL>${BaseURL}</BaseURL>
                    <numberOfUsers>${numberOfUsers}</numberOfUsers>
                    <rampupTimeInSeconds>${rampupTimeInSeconds}</rampupTimeInSeconds>
                    <numberOfLoops>${numberOfLoops}</numberOfLoops>
                    <jmeter.reportgenerator.apdex_satisfied_threshold>${apdexSatisfiedThreshold}</jmeter.reportgenerator.apdex_satisfied_threshold>
                    <jmeter.reportgenerator.apdex_tolerated_threshold>${apdexToleratedThreshold}</jmeter.reportgenerator.apdex_tolerated_threshold>
                    <jmeter.reportgenerator.report_title>${jmeterReportTitle}</jmeter.reportgenerator.report_title>
                    <!-- if below is true then doesn't show summary of events in console log -->
                    <summariser.ignore_transaction_controller_sample_result>false</summariser.ignore_transaction_controller_sample_result>
                    <jmeter.save.saveservice.subresults>true</jmeter.save.saveservice.subresults>
                    <!-- Generate JMeter report with only transaction labels and data without sub samplers -->
                    <!--jmeter.reportgenerator.exporter.html.show_controllers_only>true</jmeter.reportgenerator.exporter.html.show_controllers_only-->                      
                </propertiesUser>
                <generateReports>true</generateReports>
            </configuration>
        </plugin>
    </plugins>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>3.0.0-M4</version>
        </plugin>
    </plugins>
</reporting>

您的测试未成功执行:

因此结果文件为空,因此 JMeter 无法生成 HTML Reporting Dashboard

实际上 not-properly-handled NPE indicates that a big problem in the code as yoiu shouldn't normally see issues like this in more or less mature software so you can report the issue via JMeter Bugzilla as JMeter shouldn't throw a NPE, it should rather report a human-readable message that the results file is empty suggesting inspecting jmeter.log file 由于可能的原因。

所以你应该在 target/jmeter/logs 文件夹下看到 your_test_script_name.jmx.log 文件。,我很确定您会在那里找到测试脚本失败的根本原因。

查看 How to Use the JMeter Maven Plugin 文章以获取有关 运行 通过 Apache Maven 进行 JMeter 测试的更多信息

运行 从 GUI 模式测试一次并确认测试正确执行。然后从 CLI 模式 运行。