I would like to use multiline strings in the Examples section of The Scenario Outline. How to do that ?
eg
Scenario Outline:
Given something
When `<action>` happens
I should get elaborative `<duuh>`
Examples:
|action|duuh|
|"""
tututuut
"""|"""blablabla m
ultiline"""|
it does not look clean neither works
Each scenario outline can have multiple tables with examples. The parameters in scenario outlines allow test runners to paste the examples from the table into the outline.
Feature file can contain multiple scenarios or scenario outlines. We can write all possible Scenarios of a particular feature in a feature file. By using the keyword "Scenario" or "Scenario Outline", One Scenario can be separated from another.
Scenario and Scenario Outline serve different purposes, they are written the same way but Scenario Outline takes user data in the form of Example table and run the scenario. So rather than duplicating same scenario with different data, one can write one Scenario Outline and write all data in Example table.
What I did, was to separate the long strings in files (in my case it was pieces of json) and when I need the strings, I just load the needed file.
I did it in Grails, but should be very similar:
Method to read the file
static String getMockJsonFile(String fileName){
new File("${BOOKING_JSON_FILES_PATH}${fileName}.json").text
}
Json file
"collectionSummary": {
"attempts": [
{
"collectionMethod": {
"creditCardCollectionMethod": {
"id": 2,
"collectionMethodType": "CREDITCARD",
"creditCardType": {
"code": "CA",
"name": "Master Card Credit"
}
}
},
"billingCurrency": "EUR"
}
],
"creationDate": "2017-05-30 14:46:19",
"currency": "EUR",
"collectedAmount": 9.1
}
If you set """ triple quotes in the file, the string result will have it too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With