Forum Discussion
- KittRegular Contributor
I believe you can do this by tweaking one or more of the pipeline task options. I would suggest adding a SendEmail task (from Azure marketplace) after the VS Test Task and adjusting the task settings by expanding the 'Control Options' > select Enable > then set the 'Run this task' option to your desired option - ie: if all test succeed, if pervious task fails, or you own custom condition [Azure reference] .
Personally, I've only sent email alerts from within TestComplete when certain failures occur, so I can't speak to the flexibility of the Azure task settings. However using the onError event handler and the SendMail [TestComplete reference] method you can create some logic that can define when to send an email and to whom. For example, if certain 'critical' errors occur or a certain message is posted to the log, or an error occurs in a certain environment, then send an email:
In this example I set a project suite variable at the start of each test case that says what area I'm testing and which environment I'm in. If an error occurs in a certain area I send out an email with basic reference info and a screenshot attached. Additionally, it handles the environment I'm in by sending an email to only me if it's in QA or to the larger distribution group if the error occurs in UAT.
```
function EventControls_OnLogError(Sender, LogParams)
{// envt handler
var page = Sys.Browser("*").Page("*");
switch(ProjectSuite.Variables.Environment) {
case "QA":
var alertRecipient = "me@company.com";
break;
case "STG":
var alertRecipient = "group@company.com";
break;
}
/* Payment failure alert OR check for certain log message with: if (equal(LogParams.MessageText, "Send email when this message is written to the log")) */if (equal(ProjectSuite.Variables.ServiceType, "Payments")) {
LogParams.Locked = false;
LogParams.Priority = pmHighest;
LogParams.FontStyle.Bold = true;
LogParams.FontColor = clSilver;
LogParams.Color = clRed;
// send alert email w/screenshot
if (CommonMAIN.SendEmail("noreply@sender.com", alertRecipient, "Portal Automation Failure",
"FX Failure in " + ProjectSuite.Variables.Environment + " - " + aqTestCase.CurrentTestCase.Name
+ " ERROR: " + LogParams.MessageText, Log.Picture(Sys.Desktop.Picture(), "Image of the error"))) {
Log.Checkpoint("| Alert Email Sent |");
page.Refresh();
}
else {
Log.Warning("WARNING: alert email unsuccessful");
}
}}
```
- KittRegular Contributor
Here's another good reference on how to create a error threshold using a project variable and the onError event [TestComplete reference]
Related Content
- 10 years ago
- 11 months ago
- 6 years ago
- 12 years ago
- 4 years ago
Recent Discussions
- 43 minutes ago
- 2 hours ago
- 8 hours ago