Marcus
Marcus

Reputation: 141

Karate-config.js, Is it possible to run java method after every karate scenario?

I found in the karate docs that the java method can be run like this:

* def JavaDemo = Java.type('com.app.DBUtils').prepareData(arg1, arg2)

I created karate-config.js file where I stored environment variables. Now I need to run some java methods after every scenario, but just for some environments. So I have there some conditions.

But I didn't find a way to run a java method from karate-config.js after every scenario. Is it possible?

Upvotes: 1

Views: 1818

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58128

Yes if you wrap it in JS or a Feature: https://github.com/intuit/karate#hooks

var fun = function(){ var MyClass = Java.type('com.myco.MyClass'); MyClass.doWork() }
karate.configure('afterScenario', fun);

Upvotes: 1

Related Questions