I would like to call a method after each scenario from a single Feature with Karate, do we have something like @AfterScenario
in Karate? Or is there any other way to achieve this functionality?
Asked
Active
Viewed 5,470 times
1

ernitingoel
- 621
- 2
- 9
- 24
1 Answers
4
Yes, there is an afterScenario
hook. Please refer the docs: https://github.com/intuit/karate#hooks
* configure afterScenario = function(){ karate.log('hi') }

Peter Thomas
- 54,465
- 21
- 84
- 248
-
Whether Karate.config.js process the After scenario for each scenario? If not, we need to call the after scenario in all the feature file. – Ashok kumar Ganesan Jun 15 '20 at 17:03
-
@AshokkumarGanesan yes – Peter Thomas Jun 15 '20 at 17:06
-
The **YES** is for call the scenario in all the feature file? – Ashok kumar Ganesan Jun 16 '20 at 03:26
-
@AshokkumarGanesan yes. (I'm being as vague as your question. ask a new (good) question if needed) – Peter Thomas Jun 16 '20 at 04:06
-
What he is asking is if there is an place where you can put afterScenario so that you don't have to put it in each feature file. I see that karate-config.js is run BEFORE every scenario. That may be sufficient to add it using karate.configure("afterScenario", "function(){ karate.log('hi') }") – PBMax Feb 12 '21 at 21:51
-
@PeterThomas That didn't work when I just tried using Karate 0.9.6 – PBMax Feb 16 '21 at 00:55
-
@PBMax follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Feb 16 '21 at 01:55