Adding a ServiceCommand Test
With ServiceCommand tests you can send HTTP request. Normally, this would be used in Bridge context to send requests to the Bridge API or to the xUML Runtime API via REST. However, this test can also be used to send a requests to an arbitrary target that understands HTTP.
To add a ServiceCommand test to your test suite, select ServiceCommand from the list of tests actions (see Creating Additional Tests).
Fill in the fields according to the description below:
Field | Description | Example |
---|---|---|
Service | Specify the name of the Bridge service you want to send a requests to. | |
Name | Specify the name of the test. | |
Protocol | Specify the protocol. |
|
Host | Specify the host, the service has been deployed to. |
|
Port | Specify the port of the recipient, e.g. Bridge port or control port of the service you want to send a requests to. |
|
URL Path | Specify the URL path of the request target, e.g. the Bridge API. |
|
Request File | Specify a path to a file that contains data for PUT or POST requests. | |
HTTP Header File | Specify a path to a HTTP header file, if you need HTTP headers, e.g. for authentication. The file should have the extension .httpheader. | |
Method | Specify a HTTP method, default is POST, if nothing is specified. |
|
Variable Store | Specify a path to a file that stores variable values. Refer to Working With a Variable Store for more details. | |
Variable Name | Specify the name of the variable to store to the variable store. Refer to Working With a Variable Store for more details. | |
Variable XPath Expression | Specify an XPath expression to extract a value from the request response to store it to the variable store. Refer to Working With a Variable Store for more details. |
For requests that occasionally do not return a response body, like e.g. PUT requests, it is not required to compare the results of the test. In this case, you can remove the compare step on tab General.
Working With a Variable Store
You can use a variable store with ServiceCommand tests to pass data from one test to others.
The first ServiceCommand test stores a value from the test response to the variable store using
Variable XPath Expression to extract the value from the response
Variable Name to specify the name of the variable the value is stored to
Variable Store to save the variable and its value to a file
The second ServiceCommand test replaces placeholders in the request file with values from the variable store using
Variable Store to load the variable values from file
This way, the variable value is used in the request of the second test.
Storing Variables to a Variable Store
Specify Variable XPath Expression, Variable Name and Variable Store in a ServiceCommand test. The value extracted by the XPath expression will be stored in the file specified by Variable Store under name of Variable Name.
You need at least one ServiceCommand test with this settings to store a value.
Retrieving Variables From a Variable Store
Specify an existent Variable Store in one or more subsequent ServiceCommand test to retrieve values that have been previously stored. All occurrences of variables in form of ${variable name}
in a given request file will be replaced by the value from the variable store.
Thus, you can only use variable stores with requests that use a request file. You cannot replace path variables of a REST request with values from a variable store.