what is the best way to send test reports as an email?
My framework has WebDriver + TestNG
what is the best way to send test reports as an email?
My framework has WebDriver + TestNG
For Jenkins..
Go to Your Project > Configure > Post-build Actions > Editable Email Notification
.
Then click on Advanced Settings....
There is a box named Pre-send Script.
def reportPath = build.getWorkspace().child("test-output/emailable-report.html")
msg.setContent(reportPath.readToString(), "text/html");
Copy that and paste it into the box. Then Save it. That will generate the colourfull page and you can send it as a report via email.
Couple of ways, you can use jenkins to schedule your tests or run them. It gives sending emails as a post build option. Other way is, if you are using maven as a build tool, you can use plugins which send emails. mail-maven-plugin and maven postman plugin are some results on search.
5. You will see a field named "Attachments"
6. In that field just enter: **/emailable-report.html
The following was helpful to me:
I've created solution without Jenkins I used to Sending mail attachment using Java to sanding mail with Javamail
In TensNG annotation @AfterTest I created method to send email with attachment
EmailUtil.reportByEmail("target/surefire-reports/emailable-report.html");
and in Windows I've created batch file launchtests.bat whitch contains firstly step to run clean test, and secondly to launch one test without clean, to send previous results.
chdir C:\Users\QA\tests\tests
start /wait cmd /k "mvn clean test && exit" /secondary /minimized
REM to send email with results in file, whitch was composed after test suite (mvn without: clean)
start /wait cmd /k "mvn test -Dgroups=FakeGroupForSendMail && exit" /secondary /minimized
then, of course I've created tast in Windows to launch this batch every night.