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
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
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();
}
}