Can anyone tell me how to send the test results via email after running tests using command line?
I know the command 'SendEmail' to send the results in email. But there is problem of results file log as it will be different daily. How can I find the correct log file and send it via email daily.
As far as I understand, the problem is caused by the fact that you cannot determine the exact path to the existing log file. I suggest that you save the current log (for example, to an MHT file) by using the Log.SaveResultsAs method from script specifying the path to the file that will be used in the SendEmail function. Please read the "Log.SaveResultsAs" help topic to learn more about the method.
After running tests I used OnStopTest general events to send e-mail. Below is my code to send e-mail in vbscript.
<font class="small">Code:</font><hr /><pre>
path = Project.filename 'Defines the path of the CRUD project
set fso = createobject("scripting.filesystemobject") 'Create file system object
getbase = fso.getbasename(path) 'get the base file name from project path
path2 = "D:\TestCompleteResults\AccountsReceivable\" 'Path to directory that result will save to
d = aqDateTime.Today()
DisplayDate = aqConvert.DateTimeToFormatStr(d, "%B-%d-%Y")
t = aqDateTime.Now()
DisplayTime = aqConvert.DateTimeToFormatStr(t, "%H'%M'%S")
FileName = getbase + "_" + DisplayDate + "_" + DisplayTime + ".mht"
Log.SaveResultsAs path2 + FileName, 2 'Save the log result as .mht file
Log.message(FileName) 'Defines file what the file name and extension will be save as eg. 02CRUD.mht
If Log.ErrCount>=1 Then
Log.Message("The Test Failed")
Call SendMail("firstname.lastname@example.org, email@example.com", "mail.teamfinancial.com", "Long Tran", "firstname.lastname@example.org", "Test email log", "Hello Mike, this is a test for automatic e-mail for Customer File CRUD", path2 + FileName)
Log.Message "Mail was sent"
Log.message("Mail was not sent")
I created a folder locally "D:\TestCompleteResults\AccountsReceivable\" and stores the results in there. Everytime the test run it will save the results in .mht with the file name + date and time.
Hope this helps