1

I'm building an api test suite using karate for my project. So far it's been a great experience using the tool and have not had any major blockers. However now we are planning to set up an email trigger that helps us to raise an alarm if there are any failed tests once the test suite has run to completion.

The idea is to have an email triggered if there are any failed tests in the test suite. But I am unable to find anything that gives me an aftersuite functionality in karate. So once the test suite has run to completion there is no way to tell if there are any failed tests and if there are, how to do a post execution action like trigger an email etc.

So far I have tried the following:

  1. Trigger email from jenkins - this has been kept aside as a last resort since we don't need a jenkins dependency and would like to have this incorporated in the test framework itself.

  2. Make use of the Results object - we are not using a junit-maven setup in our project. So not really sure if we can make use of this. Besides we are not yet into parallel run mode

  3. This option is what gives us some hope. I read the results-json.txt file after execution is done and if there are any failures do the next action of sending an alert. But the problem is I have put this check in a feature file which will be the last feature to execute in the test suite. But for some reason the results turn out to be blank. I can only get any result from the results-json file once this feature is run after the test suite execution is completed. Which means I have to run this as a standalone feature after my test suite has run to a completion.

Could someone please suggest a way I can solve this?. I think I can make this work either if there is an aftersuite functionality that gives me the count of failed tests along with an option to do an aftersuite step or if there is a way I can read the result-json file as part of the test suite that I am running(my 3rd point). Apologies if I am missing something here as I am still pretty new to karate and exploring it's various features.

VishnuMP
  • 11
  • 2
  • if you are not willing to use java code, I'm sorry there are no options. you are welcome to contribute code to karate of course. the linked answer has a bunch of links that may give you ideas, but you may need to do more research + digging and feel free to ask another (more specific) question later – Peter Thomas Apr 14 '21 at 18:06
  • but you are right - if you can run a batch script after a test run (sequence 2 shell commands perhaps) you should be able to use the `results-json.txt` data to do what you want – Peter Thomas Apr 14 '21 at 18:55

0 Answers0