cancel
Showing results for 
Search instead for 
Did you mean: 

How to email the test result report as an attachment?

New Member

How to email the test result report as an attachment?

Hi,
I need to email the test result report in ReadyAPI but sendMail test step does not support the attachment. Is there any alternative way to do this job? 

1 REPLY 1
Contributor

Re: How to email the test result report as an attachment?

Hi Charles, I am using ant mail via groovy.

 

you would need to download following jars and copy it to ReadyAPI/Lib folder.

ant.jar

ant-javamail.jar

ant-launcher.jar

 

Also you will need to provide SMTP gateway config sucha as email host, port etc.

 

Below is my script to send an html report as an attachment.

import org.apache.tools.ant.*

//preparing an email notification
def ReportDir = context.expand ('${#Project#TestReportPath}')
def emailHost = context.expand ('${#Global#emailHost}')        
def fromEmail = context.expand ('${#Project#FromAddress}') 
def toEmail = context.expand ('${#Project#ToAddress}')
def ccEmail = context.expand ('${#Project#CcAddress}') 


//Sending an email notification 

def ant = new AntBuilder()
    ant.mail(mailhost:"${emailHost}", messagemimetype:'text/html', subject:"TestReport: APIs Functional tests", tolist:toEmail, cclist:ccEmail){
                 from(address:"${fromEmail}")
                 message("Please find the attachment for API Functional Test Report.")
                 attachments(){
                               fileset(dir:"${ReportDir}"){
                                                           include(name:"TestReport-APIFunctionalTests.html")
                               }
                 }
    }

hope this helps!

 

Best.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors