To get detailed test case reports in your emails, you need to add a custom step to your pipeline to parse the results and send a custom notification.
Here are the required steps:
Step 1: Generate a Detailed Test Report
Configure your test tool (Cypress) to output a machine-readable report file. The standard format for this is JUnit XML. You'll need to add a JUnit reporter to your Cypress configuration.
Step 2: Publish the Test Results
In your YAML pipeline, use the PublishTestResults@2 task. This task officially publishes the JUnit XML file, making the detailed results available to the pipeline.
Step 3: Add a Custom Script to Send the Email
Add a PowerShell task to the end of your pipeline. This script is responsible for:
- Finding and reading the JUnit XML report file.
- Parsing the file to get the status of each individual test case.
- Building an HTML string that lists the passed and failed tests.
- Sending this HTML as the body of an email.
Step 4: Securely Manage Your Credentials
Store your email server details (SMTP server, recipient list, etc.) in a secure Variable Group within your Azure DevOps project's Library. Do not hardcode them in your YAML file. Link this variable group to your pipeline to make the credentials available to your script.