TestProject Forum

Actions in inner classes problem- error 'No anonymous constructor was found'

Hi
I want to include a couple of actions in one class file instead of multiple. To do so I created a couple of inner classes, like this:

public class InnerClasses{
    
    @Action(name="Action1")
    public class Action1 implements AndroidAction {
        @Override
        public ExecutionResult execute(AndroidAddonHelper helper) throws FailureException {
            AndroidDriver driver = helper.getDriver();
            helper.getReporter().result("DID ACTION 1");
            return ExecutionResult.FAILED;
        }
    }

    @Action(name="Action2")
    public class Action2 implements AndroidAction {
        @Override
        public ExecutionResult execute(AndroidAddonHelper helper) throws FailureException {
            AndroidDriver driver = helper.getDriver();
            helper.getReporter().result("DID ACTION 2");
            return ExecutionResult.PASSED;
        }
    }
}

Everything compiles alright but when I try to upload it to TestProject I get the following errors:
image

Does anyone know if it’s possible? Thanks

@Shir.Simon

Right now it is not possible, each action should have a class of its own.
We will add this scenario to our improvements list and evaluate the implementation in the future.

1 Like

Ok good to know, thanks
This is a very needed option for our project

You can still extend classes or implement interfaces if that helps,
but for the time being, actions can not be declared inside inner classes.
We will update you if this will change.

I’m just curious, why do you need this aggregation/grouping under the same class?
Perhaps using a different package for different action types could also be beneficial.

We consider using TestProject, and because there is a class for every action there will be a long tree of classes which will clutter our workspace. Even with packages we’re afraid it will be difficult to find what we’re looking for

Actions are actually a replacement for the recorded steps. They are the building blocks of any test.

Do you plan to develop these actions and then use them during recording?
Or do you plan to develop a coded test and invoke these actions using an action proxy mechanism?

I’m asking these questions, in order to guide you in the right direction.
For example, perhaps using a BDD approach using the Cucumber reporter is the way to go when your actions are atomic tiny parts of a full coded test.

1 Like

Our hope is to use actions as building blocks of a coded test, and use the ui as a way for the qa team to flexibly construct scenarios.
We tried Cucumber but it wasn’t the right tool for us.

hi, did you see this message? would be great to hear your advice

Hi @Shir.Simon

We will contact you to schedule a quick demonstration of all the available options for your needs.