Jmeter ant在 build.xml 文件中,怎么设置jmeter.save.saveservice.thread_counts=true 参数
时间: 2024-10-26 21:17:55 浏览: 64
在 Apache JMeter 的 Ant 构建文件 (build.xml) 中,设置 `jmeter.save.saveservice.thread_counts=true` 参数是为了确保测试运行时保存每个样本的线程计数。以下是设置该参数的基本步骤:
1. 找到 `junit.sample_results` 部分,这是 Ant 调用 JMeter 进行测试的地方。通常它会类似这样:
```xml
<junit printsummary="yes" haltonfailure="no" showoutput="${showOutput}">
<classpath refid="junit.classpath"/>
<formatter type="plain"/>
<!-- 这里添加你的测试计划 -->
<test todir="${resultsDir}" unless="junit.testplan">
<fileset dir="${basedir}/src/test/resources/jmx/" includes="*.jmx"/>
</test>
<!-- 其他Ant任务... -->
</junit>
```
2. 将 `junit` 标签内加入 `jmeter.save.saveservice.*` 属性,指定要保存的属性。在这个例子中,将 `thread_counts` 添加进去:
```xml
<junit ...>
<!-- ... -->
<property name="jmeter.save.saveservice.response_code" value="true"/>
<property name="jmeter.save.saveservice.response_data" value="true"/>
<property name="jmeter.save.saveservice.response_data_on_error" value="true"/>
<property name="jmeter.save.saveservice.thread_counts" value="true"/>
<!-- ... -->
</junit>
```
3. 重启你的 Ant 构建过程,JMeter 就会在执行测试后生成的 .jtl 文件中包含线程计数信息。
注意:`jmeter.save.saveservice` 是一个可选属性,如果未设置,则默认值可能会有所不同。确保在 Ant 中引入了正确的 JMeter Ant task,例如通过 `antlib:jorphan` 或者 `antlib:blazemeter`.
阅读全文
相关推荐
![xml](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)