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.