问题
I am trying to get JMeter to email me the results after it runs a test plan which is intended to be run daily with success or fail and the test cases.
In the documentation it state "JMeter has extensive Email capabilities. It can send email based on test results"[1], But I cant find anything. After some research there is possibility popping up in writing a script in bean script(but grabbing the actual results is difficult again) to email or running a batch file on a cron.
The Question: Is this the only option? JMeters documentation vaguely suggests that there may be a built in way to do this through optional additions (which i have added) but no directions from there.[2] Am I missing something obvious?
[1] http://jmeter.apache.org/usermanual/get-started.html
[2] http://www.jajakarta.org/jmeter/1.7/en/usermanual/get-started.html#opt_email
回答1:
JMeter comes with SMTP Sampler which can be used to send an email with arbitrary content for instance when test has ended or error occurred or critical threshold is reached.
Theoretically you can configure SMTP Sampler to send .jtl results file i.e. somewhere in tearDown Thread Group but there is no guarantee that results will be full.
JMeter has jmeter.save.saveservice.autoflush
property which defaults to "false" so JMeter periodically stores results in .jtl file (not in the real time) You can set it to "true" to get more consistent results to email - in that case JMeter will write down every single line, however in case of immense load it may lead to massive disk IO overhead.
See Load Testing Your Email Server: How to Send and Receive E-mails with JMeter guide for example SMTP Sampler configuration.
If you decide to set autoflush property to true, the best way is to add the following line to user.properties file (in /bin folder of your JMeter installation) and restart JMeter
jmeter.save.saveservice.autoflush=true
You can also provide it as command-line argument via -J key like
jmeter -Jjmeter.save.saveservice.autoflush=true -n -t /path/to/testplan.jmx -l /path/to/results.jtl
来源:https://stackoverflow.com/questions/33632028/jmeter-result-report-emailing