问题
I have a field in my request .I don't want to parameterize the entire field.
"user": "(KGS-ABCDE-GS\n-\n)\n",
The text ABCDE in the above field needs to be updated with a dynamic user always.Rest of the content need not be changed.The user field mentioned above is a part of my whole request.
I am trying to only make the particular test to fetch a value from a variable defined in the feature file.Could you please let me know how this can be done. *def user = "HELLOUSER" "user": "(KGS--GS\n-\n)\n",
Is there a need to have a javascript or some other way to achieve this?
回答1:
Please read the docs: https://github.com/intuit/karate#rules-for-embedded-expressions
* def user = 'HELLOUSER'
* def temp = 'KGS-' + user + '-GS'
* def payload = { user: '#(temp)' }
来源:https://stackoverflow.com/questions/55337271/how-to-parameterize-a-part-of-string-in-a-field-of-the-request-in-karate