Annotation Interface UiTest


@Target(TYPE) @Retention(RUNTIME) @ExtendWith({org.springframework.test.context.junit.jupiter.SpringExtension.class,JmixUiTestExtension.class}) @Documented @Inherited public @interface UiTest
The annotation is used for testing Flow UI views on JUnit.

Base example:

 @UiTest
 @SpringBootTest(classes = {DemoApplication.class, FlowuiTestAssistConfiguration.class})
 public class UserViewsTest {
     @Autowired
     private ViewNavigators viewNavigators;

     @Test
     public void navigateToUserListView() {
         viewNavigators.view(UserListView.class)
                 .navigate();

         UserListView view = UiTestUtils.getCurrentView();

         CollectionContainer<User> usersDc = ViewControllerUtils.getViewData(view)
                 .getContainer("usersDc");

         Assertions.assertTrue(usersDc.getItems().size() > 0);
     }
 }
 
If the annotation is used on nested classes with the Nested annotation, it does not override the parameters from the annotation of the outer class.
See Also:
  • Element Details

    • viewBasePackages

      String[] viewBasePackages
      Views under these packages will be available in test.

      If not specified, all views registered in the application and in used add-ons are available.

      Returns:
      array of view packages
      Default:
      {}
    • authenticator

      Class<? extends UiTestAuthenticator> authenticator
      Class providing authentication management in tests.

      By default, SystemAuthenticator is used for authentication.

      Returns:
      class that implements UiTestAuthenticator
      Default:
      io.jmix.flowui.testassist.UiTest.DefaultUiTestAuthenticator.class
    • initialView

      Class<? extends View> initialView
      Initial view that will be opened before each test.

      Note that for application tests, by default, the Main View class specified in the application properties will be used. If it does not exist, the InitialView will be used instead.

      Returns:
      view that will be opened before each test
      Default:
      io.jmix.flowui.testassist.view.initial.InitialView.class