Introducing Mimicry - Automatic source generation for writing Masquerade Tests

Background - you can skip this if you want
In my cuba based project, I have quite a lot of end-user facing screens. I wanted to make some basic regression tests, just checking if screens would open or not since there quite some changes while developing.

I started by taking xml screen descriptors and through regex and excel tried to make classes to represent the screens so I could use them in Masquerade based tests. Same story with the menus.

Then I tried generating some stuff, and I guess the addon is the result. @knstvk proposed I would present it here on the forum for review and feedback.

Mimicry
Mimicry parses xml screen descriptor files and the web-menu.
Based on this it generates java files with all of the Masqureade components wired in.
It is still a work in progress and a poc, but I got some very nice results both on my own code and on eg. petclinc sample.
The goal is simple, make it easier and faster to write and maintain masquerade tests by removing monkey work.
ps. this first version is a POC and is mainly ment to show the capabilities and check if people are interested in it.

The source can be found at gitlab
The plugin at Bintray

I got some pretty good results on my own screens, and fragments also seem to work. To be honest, I added some code in the latest versions without acutally being able to test it (vacation, kids, corona, …)

As a teaser though, let me present you the LoginScreen generated by Mimicry and the LoginWindow proposed in the Masquerade Readme (on gitlab I have a sample for the Petclinic owner screens). And yes, I did not include labels in the generation yet :grinning:

Masquerade LoginWindow example

import com.haulmont.masquerade.Wire;
import com.haulmont.masquerade.base.Composite;
import com.haulmont.masquerade.components.Button;
import com.haulmont.masquerade.components.CheckBox;
import com.haulmont.masquerade.components.Label;
import com.haulmont.masquerade.components.LookupField;
import com.haulmont.masquerade.components.PasswordField;
import com.haulmont.masquerade.components.TextField;
import org.openqa.selenium.support.FindBy;

public class LoginWindow extends Composite<LoginWindow> {

    @Wire
    public TextField loginField;

    @Wire
    public PasswordField passwordField;

    @Wire(path = "rememberMeCheckBox")
    public CheckBox rememberMeCheckBox;

    @Wire(path = {"loginFormLayout", "loginButton"})
    public Button loginSubmitButton;

    @Wire
    public LookupField localesSelect;

    @Wire
    public Label welcomeLabel;

    @FindBy(className = "c-login-caption")
    public Label welcomeLabelTest;
}

Generated by Mimicry

package com.haulmont.cuba.web.app.login;

import com.haulmont.masquerade.Wire;
import com.haulmont.masquerade.components.Button;
import com.haulmont.masquerade.components.CheckBox;
import com.haulmont.masquerade.components.LookupField;
import com.haulmont.masquerade.components.PasswordField;
import com.haulmont.masquerade.components.TextField;

public final class LoginScreen {
  @Wire(
      path = "loginField"
  )
  public TextField loginField;

  @Wire(
      path = "passwordField"
  )
  public PasswordField passwordField;

  @Wire(
      path = "rememberMeCheckBox"
  )
  public CheckBox rememberMeCheckBox;

  @Wire(
      path = "localesSelect"
  )
  public LookupField localesSelect;

  @Wire(
      path = "loginButton"
  )
  public Button loginButton;
}

2 Likes

Hi, Tom

Could you please clarify how does automatic generation work?
I created Cuba project with some screens, installed Masquerade and Mimicry addon.
After launching the application I specified package with screens name to Mimicry Expoter. I have got text.zip with generated files and manually added them to my project.
Also I notised that generation doesn`t work for legacy screens. Is it correct way to use Mimicry Generation or there is some another way without running application?

BR,
Julia Maistrenko

Hi,

I have tested Mimicry Generation and faced the following problems:
1.Mimicry generation implementes not for all Masqureade components. (For insnatce, for groupTable, treeTable, treeTable, calendar, datePicker, checkBoxGroup, linkButton corresponding components have not been generated)
2. If component does not have id, but has action, cuba-id generates as action id. So it is possible that several components uses the same action and as a result have tha same cuba-id. In this case Mimicry generates component with incorrect path
@Wire(path = "personsTable_create" ) instead of @Wire(path = {"personsTable", "create"})
In point of fact there is not any component with cuba-id=“personsTable_create” on corresponding screen.
3. It is not convenient to download zip, unzip it, manually put generated files to target package and change package value for each file. May be instead of creating zip, it is possible to select target package and straight put files there?

Could you please indicate in readme for which components generation is applicable and how to use it?

BR,
Julia Maistrenko

Hi @Maistrenko
thanks for the feedback. I will try to resolve as soon as I can.

1.Mimicry generation implementes not for all Masqureade components. (For insnatce, for groupTable, treeTable, treeTable, calendar, datePicker, checkBoxGroup, linkButton corresponding components have not been generated)

Actually, it is Masquerade that doesn’t implement most of these components.
I locally already added groupTable, but the other ones are missing in Masquerade:
Treetable, Calendar, datepicker, checkboxGroup, linkButton

Hi,
I created a new version 0.0.6

This version includes OptionsGroup and Grouptable. As stated above the other missing components are not supported by Masquerade, I will report an issue for that.

This version now also supports legacy screens.
All cuba built-in screens seem to be generated. Next steps are:

  • generate correct typed field (eg. TextField) instead of the generic Field
  • For legacy screens, generate buttons for windows actions

I will also make a test projects to demo how to use mimicry, both for generating the UI classes and an actual test project.

1 Like

Which version of Masquerade do you use? Because GroupTable support introduced in Masquerade 2.0.2.