1

I create automation tests for web using WebDriver and now architecture is like this:

Current Architecture

Description:

  • HelperBase.java: contains extended methods for WebDriver which could be used in any project, they are AUT independent.
  • AppHelperBase.java: class to extend HelperBase and simplify some methods for the common needs of AUT.
  • AppModuleXHelper.java files: helpers for different modules of AUT

HelperBase code:

public class HelperBase {
    /** Some JavaDoc here
    */
    @Step("some allure logging here...")
    public void clickIgnoreException(By locator, long timeoutMillis) {
        ...
    }
    ...
}

So the code in AppModuleXHelper.java looks like:

public Creature someCreationMethodForXModule(Creature creature) {
    if (creature == null) {
        ...
    }
    // All the next methods are from HelperBase.java
    clickIgnoreException(createButtonLocator, 0);
    checkFormAppear(createCreatureFormLocator, 30);
    setValueOrLogNoData(creature.name, creatureNameInputLocator);
    ...
}

After two years HelperBase.java has become too big and it is difficult to search for methods it is difficult to support this class.

So I desided to break it into different helpers: ClickHepler, TableHelper, VisibilityHelper etc. And the architecture seemed to be transforming into:

Architecture to discuss

So now HelperBase just delegates calls to different helpers:

public class HelperBase {
    private ClickHelper clickHelper;

    public ClickHelper clickHelper() {
        if (clickHelper == null)
            clickHelper = new ClickHelper();
        return clickHelper;
    }
    ...
}

But I'd like to keep simplicity of AppModuleXHelper.java and call all the methods without mentioning their helper:

clickIgnoreException(createButtonLocator, 0);
// but now I have to call like:
clickHelper().clickIgnoreException(createButtonLocator, 0);

Another solusuion would be to create delegation for each method of each helper in HelperBase but would require lots of code & it will not allow to see JavaDoc comments from e.g. CLickHelper:

public class HelperBase {
    private ClickHelper clickHelper;

    private ClickHelper clickHelper() {
        if (clickHelper == null)
            clickHelper = new ClickHelper();
        return clickHelper;
    }

    public void clickIgnoreException(By locator, long timeoutMillis) {
        clickHelper().clickIgnoreException(locator, timeoutMillis);
    }
    ...
}

Is there any other architecture to break HelperBase into smaller ones & to keep calls to its (now small helpers') methods as simple as they were?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.