Creating a test
First, go to the Tests page by clicking its link in the left pane menu.
You will land in a new interface that can be divided into three main areas:
- Test filters area: filter your tests by creator / tags or search them by name
- The test list, empty for the moment
- The test run list: we'll see its use later
Now, let's create a test! If you click the Add test button, you should see the following form:
The role of the name (mandatory), description and tags fields should be obvious, so let's focus on the Steps part: that's where you'll define your actions.
Adding a step
A step is simply an action in a test. Click the + button to add a new step:
You can choose from a variety of actions, organized by the type of device they require (SIM cards, smartphones, etc). You may notice a section Others with a Pause action close to the bottom-right corner: it is used to pause the test for some time. But for now, we'll not use it.
Deleting a step
Hover over the step to make the following button appear:
Filling the details of the step
Let's create an Ethernet API Call action (you can choose another one if you prefer). Once you've clicked to add it, you'll see this form:
Pay attention to these three areas:
- The owner selector (always located at the top). An owner is simply the device that the action will run on. You can override it later, before running the test.
- The action details. It is unique for each action, as it allows you to customize its behavior. In our example, you can set the URL of the API service, define the HTTP verb (GET, POST, etc), define custom headers and even override the DNS server used to resolve the API service's IP address.
- The assertions area: this is where you will define everything that must hold true at the end of the action. If it fails, the whole test fails. For API actions, the "Check that status code is equal to 200" assertion is automatically added for your convenience, but you can delete it by clicking the red cross mark symbol ❌. You can have as many assertions as you want, or none at all.
The remaining parts (the Store area and the Add custom metrics button) are only necessary for advanced use cases, so we will not cover them in this tutorial.
Now, we'll fill in our action's details. We will call the API at https://www.wikipedia.org/, using our kapptimobile-ethernet-1 device.
But wait, what if we want to reuse our test with different API urls? What if we want to test https://api.chucknorris.io/jokes/random too? Variables to our rescue!
Defining a variable
A variable is a value that can change (unlike a hardcoded value). In kapptivate Testing & Monitoring, variables can be recognized easily because they are always surrounded with brackets { and }. So, in order to use a variable in our action, we just need to type { and then the name we want to give to that variable, and then }.
As soon as your start typing the variable's name after the opening {, you'll see a new area appear, above the test steps. Its title is Private variables. What does that mean?
In kapptivate Testing & Monitoring, variables are either public or private. A private variable is a variable whose value can only be defined in the test, and cannot be overriden later. If someone else uses your test from the outside, they'll not even know that this variable exists. On the other hand, a public variable can be overriden just before running the test. Which one you choose is up to you and your preference. If you don't know, we recommend making all variables public.
Making a variable public / private
On the left of each variable name is a closed/open eye symbol. Click it to switch the variable to public/private.
Also notice that if you don't provide a value for a private variable, you'll get an error message "Value of private variable should be provided". It makes sense, since the value of a private variable can only be set when editing a test, you are required to provide a value before saving the test.
If you have a public variable, you can find it in the area titled Input variables:
If you have public and private variables, then both areas will appear: Input variables and Private variables. You'll notice that you are not required to assign a value to public variables, since you can assign one later, before running the test.
Notice that you can use variables in the owner selector too. Really, you can use variables wherever you want! So don't feel shy to use them, the only limit is your imagination.
Also know that apart from private variables and input variables, there is a third type named Output variables. These are variables that are created during the test execution. For instance, you can store the response of an API call in a variable and reuse it in a subsequent step. But this feature is beyond the scope of this tutorial and will be better explained in a dedicated page.
Warning : If you have an "*" character in your variable, then you should always place an "\" character before. This is only true for global variables.
Warning : If you have an "*" character in your variable, then you should always place an "\" character before. This is only true for global variables.
Appendix
Animated recap