Forum Discussion

sonya_m's avatar
sonya_m
Icon for Alumni rankAlumni
5 years ago
Solved

[TechCorner Challenge #6] How to Generate Email When Assertion Fails

Hello Community!

 

Today we have another task for you to help contribute to our collection of useful ReadyAPI content.

Here is the task: Create a Groovy script that will send an email when an assertion fails

Difficulty

 

The idea of the script is to run a send email test step when the assertion fails. Please note that the email should be sent if any assertion for any test step in a project fails.

To complete the task you should write a script for one of the events.

 

Good luck😊

6 Replies

  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Just a comment.

    Running a test step in events does not seem to be natural fit. Because, event can be generated from any suite, test case or test step and where should the email test step be defined?

    In general, the CI/CD does the job of sending email irrespective of test execution completed successfully or not. IMO, it may not be right idea to send an email for an assertion failure as if may bloat inbox if failures are more on a bad day/ configuration etc.
    • Hi nmrao,

       

      Yes, I agree with you that this task isn't so realistic ðŸ˜‰

      But, maybe, this is a regression test for some basic functionality that always should pass. 

       

      Or, we can make a task more accurate - send an email only if an assertion for the "Very Important" Test Step fails.