Skip to content

Instantly share code, notes, and snippets.

@artemnikitin
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artemnikitin/8952347 to your computer and use it in GitHub Desktop.
Save artemnikitin/8952347 to your computer and use it in GitHub Desktop.
Spock sample for Data Driven Testing
@Unroll("For currency #ccy and amount = #sum response will be #response_code - #response_text")
def "Check max and min sum for different currencies"() {
given: "Body for request with sum and currency"
String content = TestProperties.getRestBody(ccy, sum)
when: "Send request"
Response result = Request.send(RequestType.PUT, url, content);
then: "Check response"
result.status.contains(http)
result.body.contains(response_code)
result.body.contains(response_text)
where:
ccy |sum ||http |response_code |response_text
"RUB"|0.5 ||"HTTP/1.1 400 Bad Request"|"\"result_code\": 241"|"Amount is less than minimum"
"RUB"|15001||"HTTP/1.1 400 Bad Request"|"\"result_code\": 242"|"Amount is greater than maximum"
"USD"|0.01 ||"HTTP/1.1 400 Bad Request"|"\"result_code\": 241"|"Amount is less than minimum"
"USD"|451 ||"HTTP/1.1 400 Bad Request"|"\"result_code\": 242"|"Amount is greater than maximum"
"EUR"|0.01 ||"HTTP/1.1 400 Bad Request"|"\"result_code\": 241"|"Amount is less than minimum"
"EUR"|352 ||"HTTP/1.1 400 Bad Request"|"\"result_code\": 242"|"Amount is greater than maximum"
"KZT"|0.7 ||"HTTP/1.1 400 Bad Request"|"\"result_code\": 241"|"Amount is less than minimum"
"KZT"|70001||"HTTP/1.1 400 Bad Request"|"\"result_code\": 242"|"Amount is greater than maximum"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment