I have the following file karate-config-test.js
function fn() {
var env = karate.env; // get system property 'karate.env'
var baseUrl = "http://localhost:5000"
var config = {
env: env,
baseUrl: baseUrl
};
//open connection to message broker (mqtt, amqp)
var async_message = karate.callSingle('classpath:com/connect/apitests/commons/async_message/async_message.feature', config);
config.mqtt = async_message.mqtt
config.amqp = async_message.amqp
return config;
}
And the following feature async_message.feature
@ignore
Feature: utility that instance async message broker
Background:
* url baseUrl
Scenario: Set instance of a class AmqpUtils And MqttUtils
* def amqp = 'pippo'
Scenario: Set instance of a class MqttUtils
* def mqtt = 'pluto'
when i check the value of the variable async_message i see the variables of one scenario but not both, for example I saw only mqtt. Why is this happening? In karate documentation I read
Karate is designed so that when you do a call
of any kind, the last Scenario
is what is considered for returning variables.
In other words, the best practice is to call one Scenario
at a time. You can use tags to "isolate" scenarios if you don't like splitting scenarios into different files.