Last updated
Last updated
In this guide we're going to test a back-end server running the following scenario for post records:
request all records from the server;
add a new record;
check if the record was added correctly;
update the record and check the update with a server response;
request the updated record from the server;
check if the record on the server is updated;
delete the record;
check if the record was deleted from the server.
You'll need about 10 min to do that after running the app.
Go to our site or use the following links to download TestMace:
Windows
Mac OS
Linux
Run the installer and follow the instructions. You will be prompted to choose an installation directory.
To install TestMace on Windows run the installer as an administrator.
Once the installation is complete, run the app. You'll see a new project.
Note that all changes to the project are automatically saved in real-time.
Double click on the created request getPosts to open it and then run it with the Run button.
As you see, the request was successfully run, and you have a list of existing records in Response Area. Let's take a closer look at this window:
Here you can specify http headers and pass parameters to the request with the help of the autocomplete feature and variables.
GET — get a resource
POST — create a resource
PUT — update a resource
DELETE — delete a resource
PATCH — make some changes to a resource
OPTIONS — specify resource connection parameters
The URL field supports autocompletion and using variables. We'll take advantage of these features later.
Sending a request or a group of requests while running from the project root or a folder node.
A server response area. The Response Body tab contains parsed, JSON, and text representations of a response. On the tabs next to it you can see Response Headers and create or view existing Assertion nodes to make a request.
A new node can be created in three different ways:
Create a Scratch by clicking on + and drag and drop it to the project later.
Right-click on the parent node and choose Add node -> Request step.
Click on the button Add project node-> Add node -> Request step.
Use any of these ways to create a node and name it createPost.
Set POST as its Request type.
Chose JSON on the response body tab and add {"title": "Testing post", "content": "Sendt via TestMace"}
Click on the RUN button and send the request.
Now send the createPost request, and you'll see that the test was successful. The task is really easy. Have a look at the animation below:
Right-click on the Id value in the CreatePost node's response body.
Choose Assign to variable.
In a pop-up window choose the posts project directory as a node, enter the variable name (postId) and press OK.
It's time we sent a PUT request. Let's access the previously created record using a dynamic variable ${$dynamicVar.postId}
and update its title and content values.
Set PUT as its request type.
Body: {"title": "Testing post updated", "content": "Updated via TestMace"}
In some situations you might want to additionally verify changes in the record, because the server may give a successful response of PUT, but sending a GET request you receive the old version.
To do that create a GET request at the record's URL using a dynamic variable.
Request type: GET.
Our next step is deleting our record at the provided URL using a dynamic variable.
Request type: DELETE.
To ensure that the record was deleted from the server, create a GET request at that record's URL using a dynamic variable. We expect to get a 404 response from the server, and so we create an Assertion node:
Request type: GET
Actual value: ${$response.code}
Operator: =
Expected value: 404
In the end we've got a test set for our server that we can run in a scenario. Just go to posts and click RUN.
Watch a video of the entire process of creating a scenario described in this guide.
Unzip in the TestMace projects directory.
To make your first request create a new tab by clicking on +. При этом в зоне You'll see a new Scratch 1 node in the Scratches Area. Insert this address in the URL field: . You can now test server response right from Scratches Area or add your scratch to the project. Rename the node to getPosts for convenience.
In your project create a node named posts and move the scratch getPosts from the Scratches Area to the Project Area.
Now let's add a new post record to the server, and to do that we need to create a new node.
Insert in the URL field.
You'll get a response telling you that the record has been successfully added, but we need to check if it was added correctly. And to do that we'll use the quickest way of creating nodes. We'll compare the sent data with the data received from the server.
In Response Area open the tab with the parsed response and right-click on the title value, that you passed in the request and choose Create Assertion -> Compare -> Equal. It'll create and open the node, and as you're not going to configure it, just close it. Create an Assertion node for the Content value in the same way.
To be able to interact with the newly added node you should pass its Id to all subsequent nodes. Define a dynamic variable postId and assign to it the Id value, received in the record after running CreatePost.
To access the variable use a $dynamicVar
:
Create a node named updatePost.
URL:
Send the request and, just like we did with the POST request, create two nodes to compare sent and received title and content values.
Create a new node named getPost.
URL:
Send the request and create 2 nodes to compare title and content values.
Create a node named deletePost.
URL:
Create a new node named checkIfNodeExists
URL:
Send the request, open the Assertions and add a new node, by clicking ADD. Set the node data:
This guide will help you quickly get to know TestMace interface and its main features.