Reputation: 391
I have a DB utils java file where I need to load DB username password based on environment I am running the code on , and these environment values I need to import from karate-config.js . How to achieve this ?
Upvotes: 1
Views: 953
Reputation: 58058
Just use embedded expressions ! So if you have dbusername
and dbpassword
set in karate-config.js
:
* def config = { username: '#(dbusername)', password: '#(dbpassword)', url: 'jdbc:h2:mem:testdb', driverClassName: 'org.h2.Driver' }
* def DbUtils = Java.type('com.mycompany.DbUtils')
* def db = new DbUtils(config)
Upvotes: 2