Jmix UI Integration Testing: Sneferu 1.0 released

Hi everyone,

I have ported over the Sneferu library from CUBA platform to Jmix.

You can find it here: https://github.com/mariodavid/jmix-sneferu

If you want to learn about the changes for the migration from CUBA platform, see: Sneferu: Migration from CUBA platform


Sneferu

pyramid-theme

Sneferu is a testing library to simplify integration testing for a Jmix application. It contains APIs that allows you to express interactions and verifications with UI screens via a high-level testing language.

Overview

Instead of spending too much time and money maintaining a selenium test suite, Sneferu is the way to have very good test coverage and quality assurance at a fraction of the cost.

Via its easy-to-read language you can create integration tests that are optimized for readability, because this is what matters most for keeping a test suite maintainable & cheap to operate.

Sneferu enables you to:

  • verify any business logic in a Screen Controller
  • ensure the correct linking between a Screen XML and its Controller counterpart
  • verify correct display of any programmatic creation of Screen Components / Dialogs
  • verify the data loading from the database through declarative data loading

What Sneferu does not cover:

  • perform client-side JS-based Vaadin UI logic that is executed only in the browser (like showing the date picker popup where it is possible to select a particular date)
  • verify rendering issues in the browser

sneferu-overview

Example

@SneferuUiTest(
        authenticatedUser = "admin",
        mainScreenId = "petclinic_MainScreen",
        screenBasePackages = "io.jmix.petclinic"
)
@SpringBootTest
public class CreateVisitTest {
    
    @Test
    void aVisitCanBeCreated_whenAllFieldsAreFilled(UiTestAPI uiTestAPI) {

        // given:
        final Pet pikachu = dataManager.create(Pet.class);
        pikachu.setName("Pikachu");
        pikachu.setIdentificationNumber("025");
        final Pet savedPikachu = dataManager.save(pikachu);

        // and:
        final StandardLookupTestAPI<Visit, VisitBrowse> visitBrowse = uiTestAPI.openStandardLookup(Visit.class, VisitBrowse.class);
        visitBrowse.interact(click(button("createBtn")));

        // when:
        final StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.getOpenedEditorScreen(VisitEdit.class);

        OperationResult outcome = (OperationResult) visitEdit
                .interact(enter(dateField("visitStartField"), LocalDateTime.now()))
                .interact(enter(textField("descriptionField"), "Regular Visit"))
                .interact(select(comboBox("typeField"), VisitType.REGULAR_CHECKUP))
                .interact(select(entityComboBox("petField"), savedPikachu))
                .andThenGet(closeEditor());

        // then:
        assertThat(outcome).isEqualTo(OperationResult.success());

        // and:
        assertThat(uiTestAPI.isActive(visitEdit))
                .isFalse();

    }
}
5 Likes

Lol, I totally forgot that it only works with Jmix 1.2 :slight_smile:

So either you already switch to 1.2-SNAPSHOT, or you have to wait for Jmix 1.2 to be released :slight_smile: this will probably happen over the next weeks…

Cheers
Mario

5 Likes

Hi everyone,

with the release of Jmix 1.2.0 I also updated Sneferu to version 1.1.0, which is compatible with this Version of Jmix.

Happy testing!

1 Like