TestProject Forum
Powered by leading experts in the test automation community

Is there a way to create an addon for all platforms?

how can i create an addon that will work for Android, IOS and web?
I see that there are options for implementing AndroidAction, IOSAction and WebAction interfaces, but what if i want for everything?

Hi Aditya!

Nice meeting you :grinning:
In our SDK you have several options that you can choose from when creating an action. If you want to create an action that will fit all the platforms (Android, iOS, and Web), you need to implement the GenericAction interface, that is a part of our Java SDK.

This a simple example of generic action that generates a random number and works on all platforms:

import io.testproject.java.annotations.v2.Parameter;
import io.testproject.java.annotations.v2.Test;
import io.testproject.java.enums.ParameterDirection;
import io.testproject.java.sdk.v2.addons.GenericAction;
import io.testproject.java.sdk.v2.addons.helpers.AddonHelper;
import io.testproject.java.sdk.v2.enums.ExecutionResult;
import io.testproject.java.sdk.v2.exceptions.FailureException;

import java.util.Random;

@Test(name = "My Generic Test")
public class MyAction implements GenericAction {

    @Parameter(description = "Random number", direction = ParameterDirection.OUTPUT)
    private int result;

    @Override
    public ExecutionResult execute(AddonHelper helper) throws FailureException {
        Random rand = new Random();
        result = rand.nextInt(1000);

        helper.getReporter().result(String.format("Result = %d", result));
        return ExecutionResult.PASSED;
    }
}