首页 > 技术文章 > 运维技术-自动化-jenkins实践03-自动化测试

yuejunasia 2021-08-20 17:52 原文

 

 

jenkins 自动化测试

 

执行测试用例

同jmeter、JUnit的通常用法,在jenkins服务器安装JMeter、JUnit……之类的测试工具,

在jenkins 增加构建步骤 “Execute shell”

echo "Testing shell"
# 每次构建之前需要删除旧的测试,否则会影响旧的报告生成
rm -rf test.jtl 
# jmeter 解压目录,注意jmeter对java环境对需求
jmeter=/opt/apache-jmeter-5.4.1/bin/jmeter.sh
# 执行测试用例Request.jmx,生成测试报告test.jtl,输出html报告到./output 目录下
# jenkins  Performance Plugin插件可以识别.jtl报告并展示中构建结果中,
# html报告为静态页面可以打包发邮件给相关人员或copy到某个网站
./jmeter -n -t Request.jmx -l test.jtl -j test.log -e -o ./output

 

测试报告/性能报告

插件: Performance Plugin

 

 

 

This plugin understands the JMeter analysis report XML format, JMeter Summariser report text format, SOAPUI report in JUnit format, Iago format as recorded while parrot server is running, and LoadRunner analysis format.
This plug-in does not perform the actual analysis; it only displays useful information about analysis results, such as average responding time, historical result trend, web UI for viewing analysis reports, and so on.
To use this feature, first set up your build to run tests, then select the adequate parser for your tests (JMeter, JUnit, or Iago) and finally you have to specify the path to the different performance files. By default the plugin will use the **/*.jtl pattern for JMeter, **/TEST*.xml for JUnit tests ,**/*.log pattern for JMeter Summariser, parrot-server-stats.log for Iago, and **/*.mdb for LoadRunner.

Source data files (autodetects format): **/*.jtl

Specify the path to the Performance report files, relative to the workspace root. Plugin will be automatically detect parser for each report file.

You can specify multiple files and directories separated by semicolon.
You use an Ant 'fileset' pattern.
Default Values are:
  • JMeter reports: "**/*.jtl"
  • JMeter csv reports: "**/*.csv"
  • JMeter Summariser reports: "**/*.log"
  • Taurus reports: "**/*.xml"
  • JUnit report: "**/TEST-*.xml"
  • wrk report: "**/*.wrk"

* By default jmeter writes summariser statistics to jmeter.log. To enable logging summariser statistics to separate log file add the property to jmeter.properties file to #Logging Configuration block : "log_file.jmeter.reporters.Summariser=filename.log"

** Default time format, that JMeter used for logging is "yyyy/mm/dd HH:mm:ss". See "log_format" property in jmeter.properties file in #Logging Configuration block. *** By default wrk does not write output files. You'll need to redirect the STDOUT output for a file as in wrk [options] [url] > results.wrk

 

构建结果/测试报告展示

 

推荐阅读