【问题标题】:I am getting an error "Error generating the report: java.lang.NullPointerException" while running the JMeter script using JMeter-Maven plugin使用 JMeter-Maven 插件运行 JMeter 脚本时出现错误“生成报告时出错:java.lang.NullPointerException”
【发布时间】:2020-01-13 14:23:22
【问题描述】:

我在使用 JMeter-Maven 插件运行 JMeter 脚本时收到错误“生成报告时出错: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 pom.xml jmeter-5.0 jmeter-maven-plugin


    【解决方案1】:

    您的测试未成功执行:

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

    实际上,处理不当的NPE 表明代码中存在大问题,因为 yoiu 通常不会在或多或少成熟的软件中看到此类问题,因此您可以通过 JMeter Bugzilla 报告问题,因为 JMeter 应该不要抛出 NPE,它应该报告一条人类可读的消息,表明结果文件为空,提示 inspecting jmeter.log file 可能的原因。

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

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

    【讨论】:

    • 嗨德米特里,感谢您的回复!当我弄乱了 csv 文件路径时,我的问题得到了解决..
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 2018-08-21
      相关资源
      最近更新 更多