Contents

use doubles via api

In order to use double data in integration tests As a developer I want to mock rest services my app is consuming from

Scenario Outline: create double

  • When I create a double with "<fullpath>" as fullpath, "<content>" as response content, "<verb>" as request verb, status as "<status>" and delay as "<delay>"
  • Then there should be 1 double with "<fullpath>" as fullpath, "<content>" as response content, "<result_verb>" as request verb, status as "<result_status>" and delay as "<result_delay>"

Examples:

fullpathcontentverbresult_verbstatusresult_statusdelayresult_delay
/api/somethingcreatedPOSTPOST2002000
/api/ssschangedPUTPUT20120100
/api/asdfsfremovedDELETEDELETE30030011
/api/sometext contentGETGET30330322
/api/some?a=3&b=ddmore contentGET20033
/api/emptyPOSTPOST20044
/api/fileHEADHEAD20055
/api/filePATCHPATCH20066

Scenario Outline: create a double with a url pattern

  • When I create a double with "<pathpattern>" as pathpattern, "<content>" as response content, "<verb>" as request verb, status as "<status>" and delay as "<delay>"
  • Then there should be 1 double with "<pathpattern>" as pathpattern, "<content>" as response content, "<result_verb>" as request verb, status as "<result_status>" and delay as "<result_delay>"

Examples:

pathpatterncontentverbresult_verbstatusresult_statusdelayresult_delay
^\/api\/.*$createdPOSTPOST2002000
^.*\/\?nocache=\d+$changedPUTPUT20120100
^[a-zA-Z]\/123$removedDELETEDELETE30030011

Scenario: view created double details

  • When I create a double
  • Then I should be able to get json representation of that double from response

Scenario Outline: request fullpath that matches double

  • Given there is double with "<fullpath>" as fullpath, "<content>" as response content, "<verb>" as request verb and "<status>" as status
  • When I "<verb>" "<fullpath>"
  • Then I should get <status> as response status and "<content>" in response content

Examples:

fullpathcontentverbstatus
/api/somethingcreatedPOST200
/api/ssschangedPUT201
/api/asdfsfremovedDELETE202
/api/some?a=3&b=ddmore contentGET203
/other/apiGET303
/patch/apiPATCH200

Scenario Outline: request a path that matches double a path pattern

  • Given there is double with "<pathpattern>" as pathpattern, "<content>" as response content, "<verb>" as request verb and "<status>" as status
  • When I "<verb>" "<fullpath>"
  • Then I should get <status> as response status and "<content>" in response content

Examples:

pathpatternfullpathcontentverbstatus
^.*$/api/somethingcreatedPOST200
^/api/.*$/api/ssschangedPUT201
^\/api\/some\?a=\d&b=[a-z]{2}$/api/some?a=3&b=ddmore contentGET203

Scenario Outline: request fullpath that matches multiple doubles

  • Given there is double with "<fullpath>" as fullpath and "<content>" as response content
  • And there is double with "<fullpath>" as fullpath and "<content2>" as response content
  • When I "GET" "<fullpath>"
  • Then I should get "<content2>" in response content

Examples:

fullpathcontentcontent2
/api/somethingtest contentanother content
/api/some?a=3&b=ddmore contentsome text

Scenario Outline: request fullpath that matches the full path of a double and a url pattern of another double

  • Given there is double with "<fullpath>" as fullpath and "<content>" as response content
  • Given there is double with "<pathpattern>" as pathpattern and "<content2>" as response content
  • When I "GET" "<fullpath>"
  • Then I should get "<content>" in response content

Examples:

fullpathcontentpathpatterncontent2
/api/somethingtest content^/api/.*$more content
/api/some?a=3&b=ddtest content^\/api\/some?a=\d+&b=d[a-z]$more content

Scenario Outline: request full path that matches more than one path pattern

  • Given there is double with "<pathpattern>" as pathpattern and "<content>" as response content
  • Given there is double with "<pathpattern2>" as pathpattern and "<content2>" as response content
  • When I "GET" "<fullpath>"
  • Then I should get "<content2>" in response content

Examples:

fullpathpathpatterncontentpathpattern2content2
/api/sam^.*$test content^\/api\/.*$more content
/api/some?a=123&b=dd^\/api\/some\?a=\d+&b=d[a-z]$test content^\/api\/some\?a=\d+&b=d[a-z]$more content

Scenario: request fullpath that does not match any double

  • Given there are no doubles
  • When I "GET" "/api/something"
  • Then I should get 404 in response status

Scenario: clear doubles

  • Given there are some doubles
  • When I delete all doubles
  • Then there should be no doubles

Source: features/rest_api/doubles.feature at commit 63ec7a17, Rest Assured (Apache-2.0 license).