Custom Steps

Using Custom Steps you can define new steps in a programming manner.
This way you can create new Testerum integrations or you can define steps that require the full flexibility of a programming language.


In order to define new Custom Steps you can download our sample project from GitHub: Testerum Custom Steps Sample Project


Testerum Custom Steps Sample Project is a Java project and in order to compile and execute it you need the following beforehand:


Verify installation

Before you start making any changes is better to compile the project to see if everything is setup correctly. For this you need to execute the maven package command: mvn package

Test Execution

There are 3 ways to execute the tests in this project:

  1. Using Testerum UI you can open the Testerum Tests attached to this projects:
    In order to see the Custom Steps changes in the UI you need to compile the project by executing: mvn package
  2. Using your IDE, you can open the class: <testerum_custom_steps_project_path>src/test/java/com/testerum/ and execute it as a JUnit test. More about jUnit integration you can find here: JUnit
  3. Executing the Maven command: mvn test

Project Structure

In this project you will find the following directories structure:
This directory follows the Maven standard. It's the place where you can define the source code of your custom steps.
This directory is created by Maven. It contains the .jar file that is the compiled source code.
This directory contains the Testerum Tests.

How to create a Custom Step

Custom Step Example:
package custom;

import com.testerum_api.testerum_steps_api.annotations.steps.Given;
import com.testerum_api.testerum_steps_api.annotations.steps.Param;
import com.testerum_api.testerum_steps_api.test_context.logger.TesterumLogger;
import com.testerum_api.testerum_steps_api.test_context.test_vars.TestVariables;

public class SimpleSteps {
    private final TesterumLogger logger = TesterumServiceLocator.getTesterumLogger();
    private final TestVariables testVariables = TesterumServiceLocator.getTestVariables();

    @Given(value = "I am logged in with the role <<roleName>>",
           description = "Step description")
        public void login(@Param(description = "Param description") String roleName) {
  "Login with the role " + roleName);
            testVariables.set("ROLE_NAME", roleName);

In order to create a new Custom Step you need to create a new Java class with a method annotated with one of the following annotations:

These annotations can have the following parameters:
This property accepts a String that defines the step name and the parameters. A parameter can be defined using the pattern: <<parameterName>>. The parameter name used in this expresion should be the same as the parameter name used in the method definition.
Step documentation will be shown in the interface and the text can be written using the Markdown syntax.
Defines the tags for this step.
In case the step has parameters then you need to define these parameters also as the method parameter annotated with @Param annotation.
The method's parameters needs to have the same names as the parameters used in the step definition.
Parameter documentation that will be shown in the interface and the text can be written using the Markdown syntax.
Boolean value that specifies if this parameter is required or not.
In case you want to have a custom parameter serializer from the String that is saved in the file and back then you need to implement the interface com.testerum_api.testerum_steps_api.transformer.Transformer and set a class reference to this implementation as the value of this parameter.


To log information to the console the best option is to use the class TesterumLogger.
You can see an example on how to access it and use it in Custom Step Example at lines 10 and 16.

Variable context

Each Testerum test has allocated a variable context where all the global variables, scenario variables, and step defined variables are present.
In case you want to access or add variables in this context you can use the class TestVariables.

You can see an example of how to access the Variable Context and how to add a variable that can be used by other steps in Custom Step Example at lines 11 and 17.

You can see the Variable Context as a Map where all the test variables are stored and that can be accessed by any step or expression in the test. This Variable Context is reset between the tests.


Testerum allows you to define hooks in a programming way by annotating a method with one of the following annotations:
will execute once before any tests are executed
will execute before each test
will execute after each test
will execute once after all the tests have been executed


Testerum allows you to define generic settings that can be later used in your steps.
Custom Setting Example:
package settings;

import com.testerum_api.testerum_steps_api.annotations.settings.DeclareSetting;
import com.testerum_api.testerum_steps_api.test_context.logger.TesterumLogger;
import com.testerum_api.testerum_steps_api.test_context.settings.RunnerSettingsManager;
import com.testerum_api.testerum_steps_api.test_context.settings.model.Setting;
import com.testerum_api.testerum_steps_api.test_context.settings.model.SettingType;

    key = Settings.MY_SETTING_KEY,
    label = "My Setting",
    type = SettingType.TEXT,
    defaultValue = "Success is not the key to happiness. Happiness is the key to success. If you love what you are doing, you will be successful.",
    description = "This is the description of my Setting",
    category = Settings.MY_SETTING_CATEGORY
public class Settings {
    public static final String MY_SETTING_KEY = "MY_SETTING_KEY";
    public static final String MY_SETTING_CATEGORY = "My Settings";

    private final TesterumLogger logger = TesterumServiceLocator.getTesterumLogger();
    private final RunnerSettingsManager settingsManager = TesterumServiceLocator.getSettingsManager();

    public void logMySetting() {
        Setting setting = settingsManager.getSetting(MY_SETTING_KEY);"MY SETTING = " + setting.getResolvedValue());
img 1
Custom Setting UI

In the img 1 you can see how the Custom Setting looks in the UI.

In order to create a custom setting you need to annotate a class with the @DeclareSetting annotation.
The DeclareSetting annotation parameters are:
This property accepts a String value that can be used to retrieve the setting value. Example on how to retrieve the setting value of a setting with the key "MY_SETTING_KEY": TesterumServiceLocator.getSettingsManager().getSetting("MY_SETTING_KEY").getResolvedValue()
The text that will be displayed on the top of the input box.
Enum property that accepts one of the values: BOOLEAN, NUMBER, TEXT, ENUM, FILESYSTEM_DIRECTORY.
In case you set the type ENUM, then you can use this property to specify the possible values of the enumaration.
Sets the default value of the setting
You can define the description of this setting. In order to create a rich text you can use the Markdown syntax.
A String that defines the name of the setting group. All the settings with the same category name will be grouped in the same screen.


In order to make your Custom Steps implementation available for Testerum UI, you need to compile the project using the Maven command: mvn package
After the Maven compilation, a .jar file is created in the target directory. Testerum loads the steps library from 2 directories: If you copy this .jar file in one of these directories, Testerum will load your custom steps definitions.
If you copy your .jar file in the <testerum_tests_project_path>/basic_steps your custom library will be shared together with your steps in your version control system and this way all your team members will benefit from your custom steps without having to do any changes.