Reputation: 547
I would like to get a common variable for all features. Ex: base URL and path (in some features). I don't understand well in Karate official tutos what to do exactly. I put in user.feature
`Background:
* url urlBase
* path users
In karate-config.js
function() {
var env = karate.env;
karate.log('karate.env system property was:', env);
if (!env) {
env = 'dev';
}
var config = {
env: env,
appId: 'my.app.id',
appSecret: 'my.secret',
baseURL: 'https://someurl/',
users: 'users'
};
karate.configure('connectTimeout', 5000);
karate.configure('readTimeout', 5000);
return config;
}
and in my runner class:
@RunWith(Karate.class)
@CucumberOptions(features = "classpath:features/users/User.feature")
public class TestRunner{
}
}
User.feature and karate-config.js are in the same folder and Runner class is in another. Is it right? or I need more things to specify?
Upvotes: 4
Views: 5326
Reputation: 58088
No this is not right. I suggest you refer to the quickstart documentation of Karate where you can generate a simple project. Get that running first, and then try to set the URL from the karate-config.js
. All the best.
Upvotes: 3