Http Call (http:call)
Http Call (http:call)
Client applications use HttpCall to comunicate with a HttpServer.
So you can work with RestAPIs from any Webservice.
Our examples are for https://api.training.testifi.io/
Usage:
<http:call url=""! method=""! payload=""? contentType=""? accept=""? expectedResponseStatus=""? secured=""? targetFile=''?
http:port=""? http:user=""? http:password=""? proxy=""? proxyUser=""? proxyPassword=""?/>
! - mandatory, ? - optional
The Port of the wished Server can be added in URL like: http://host.com:8080/rest/api/2/issue
Examples
Good Practices
1. Create a Step for the basic call with the authorization
advantage: if something changes in the authorization, we have to change it just here
petstoreCallStep.tto version <= 2.2.10-GA
<http:call url="${@config('baseUrl')}${suffix}">
<http:request-header headerName="api_key" value="special-key" />
<response-get name="lastResponse"/>
<echo message="Response is : ${lastResponse}"/>
</http:call>
petstoreCallStep.tto version >= 2.2.20-GA
<custom-building-block
id="petstoreCallStep"
mandatoryParameters="suffix,method"
description="create the basic call to the api">
<http:call url="${@config('baseUrl')}${suffix}">
<http:request-header headerName="api_key" value="special-key" />
<http:get-response-body name="lastResponse"/>
<echo message="Response is : ${lastResponse}"/>
</http:call>
</custom-building-block>
2. Implement the specific methods as a separate step using the basic call step
make sure to add parameters in need
getPetFindByStatus.tto
<custom-building-block
id="getPetFindByStatus"
optionalParameters="query"
description="find pets by status get call">
<petstoreCallStep method="get" suffix="/pet/findByStatus${query!''}"/>
</custom-building-block>
3. Call it with parameters wherever you need
using it in a Scenario
<scenario id="getPetByStatusScenario">
<test-step description="Given I call pet api get method with the given status" testData="" expectedResult="">
<getPetFindByStatus query="?status=${status}"/>
</test-step>
<test-step description="Then all the pet from the result has the given" testData="" expectedResult="The number of pets in the response are equal to the number of pets with given status in the response">
...
</test-step>
</scenario>
4. Add the parameter in a suite
using it in a Suite
<suite id="demo-test-petstore:regression"
externalId="DEMOTESTS-117"
testplanKey="5cae21ad-153e-4e9a-acf6-521ac4a66a5a"
testplanSummary="Petstore API Tests"
testplanDescription="Tests for Petstore API"
executionName="petstore">
<getPetByStatusScenario
externalId="DEMOTESTS-114"
testId="51fd9df3-b529-4779-ac2e-8fe46f42524f"
testDescription="Get all available pets"
testSummary="Get Pet by Status - Available"
status="available"/>
<getPetByStatusScenario
externalId="DEMOTESTS-115"
testId="41ef2dc3-18cc-4dae-a3fb-ab10ba6ee1f2"
testDescription="Get all pendin pets"
testSummary="Get Pet by Status - Pending"
status="pending"/>
</suite>
Related content
Http Request Header (http:request-header)
Http Request Header (http:request-header)
More like this
Http Response Header (http:response-header)
Http Response Header (http:response-header)
More like this
Http Get Response Status (http:get-response-status)
Http Get Response Status (http:get-response-status)
More like this
Http - API Testing
Http - API Testing
More like this
Response Get (response-get)
Response Get (response-get)
More like this