오이 테스트의 시나리오 개요에서 여러 다중 끈을 얻는 방법 작업을 수행하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/5056976

  •  15-11-2019
  •  | 
  •  

문제

시나리오 개요의 예 섹션에서 다중 링 문자열을 사용하고 싶습니다. 어떻게해야합니까?

예 :

Scenario Outline:
  Given something
  When `<action>` happens
    I should get elaborative `<duuh>`
  Examples:
    |action|duuh|
    |"""
    tututuut
    """|"""blablabla m
    ultiline"""|
.

에서는 깨끗하지 않습니다.

도움이 되었습니까?

해결책

I prioritize the cucumber output, not the Gherkin input, although first prize is for both to be beautiful. So multiline example values don't make sense for me, because they absolutely wreck the cucumber output.

Cucumber encourages readable output for multiline data with doc strings. It encourages readable output for data matrices with scenario outlines. I don't think it encourages readable output of multiline data matrices.

If you could come up with great examples of how the output would look in such cases, they might be well received on the Cukes forum.

Alternatively, if all you're trying to do is iterate over multiline data in your Cucumber features, come up with mnemonic names for the multiline data, provide those mnemonics in the Examples matrix of your Scenario Outline, and treat the mnemonics as the names of fixture files that you read for the actual data in your glue code.

다른 팁

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.

Have you considered using \n in your strings to denote the carriage return?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top