1

I am able to iterate over data in json array in karate framework via scenario outline but unfortunately it stopped recognizing any java interop function calls inside scenario outline.

For Ex:

Scenario Outline: Publish NewAccount kafka messages reading accountIds from dynamic csv file new-account api and Validate data in database Given path '/new-account'

And messageHeader.message_type = 'NEW_ACCOUNT'
And messageHeader.publisher_id = 'Customer'
And newAccount.messageHeader = messageHeader
And newAccount.accountNumber = <account_id>

And header Content-Type = 'text/plain'

And request <account_id>

When method post

Then retry until status 200

* call initializer.sleep 1

  * print  'row: ', __row

#Validate DB entries in journal table for new account
  * def journal_query = "SELECT * FROM journal where account_number ="+newAccount.accountNumber*1
  * print "query==",journal_query
* def accounts = call initializer.dbUtils.readRows(journal_query)
* match accounts == '#[1]'
* match accounts[0].account_number == <account_id>*1
* match accounts[0].account_sub_type == 'CASH'
* match accounts[0].entry_type_code == 'B'
* match accounts[0].firm == 'NFSC'

new_account.feature:232 - evaluation (js) failed: initializer.dbUtils.readRows(journal_query), javax.script.ScriptException: TypeError: initializer.dbUtils.readRows is not a function in at line number 1 stack trace: jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:477)

Does anybody has any idea why? and how to fix this issue.

sonal
  • 11
  • 1
  • please note i have initialized java dbutils class in initializer.feature file--- * def initializer = callonce read('../common/initialize.feature') * def messageHeader = initializer.populateHeader(read('../../data/bookkeeping/messageHeader.json')) * def newAccount = read('../../data/bookkeeping/new_account_record.json') * def newAccountCsv = read('../../data/bookkeeping/new_account_record.csv') – sonal Sep 17 '20 at 18:37
  • -- i can see account ids defined in csv file are read correctly only thing its failing at calling java interop functions in scenario outline- same calls work fine when we are using scenario or iterating over data from examples using scenario outline. Any help would be appreciated. – sonal Sep 17 '20 at 18:40
  • this is absolutely the kind of question where you should follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Sep 17 '20 at 18:42

0 Answers0