Package io.jmix.ui.testassist.junit
Class JmixUiTestExtension
java.lang.Object
io.jmix.ui.testassist.junit.JmixUiTestExtension
- All Implemented Interfaces:
- org.junit.jupiter.api.extension.AfterEachCallback,- org.junit.jupiter.api.extension.BeforeEachCallback,- org.junit.jupiter.api.extension.Extension,- org.junit.jupiter.api.extension.ParameterResolver
public class JmixUiTestExtension
extends Object
implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.ParameterResolver
Extension starts Vaadin UI before each test and configures screen packages,
 main screen id, username to perform authentication. For instance:
 
 @ExtendWith(SpringExtension.class)
 @ContextConfiguration(classes = {DemoApplication.class, UiTestAssistConfiguration.class})
 public class UserBrowseTest {
     @RegisterExtension
     protected JmixUiTestExtension uiTestExtension = new JmixUiTestExtension()
             .withAuthenticatedUser("admin")
             .withScreenBasePackages("com.company.demo.screen")
             .withMainScreenId("MainScreen");
     @Test
     protected void openUserBrowse(Screens screens) {
         UserBrowse screen = screens.create(UserBrowse.class);
         screen.show();
     }
 }
 
 Screens bean can be obtained from method parameters or via BeanFactory.getBean(Class).- See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) protected org.springframework.context.ApplicationContextgetApplicationContext(org.junit.jupiter.api.extension.ExtensionContext context) protected AppUIgetAppUI(org.junit.jupiter.api.extension.ExtensionContext context) String[]protected org.junit.jupiter.api.extension.ExtensionContext.StoregetStore(org.junit.jupiter.api.extension.ExtensionContext context) protected voidopenMainScreen(org.junit.jupiter.api.extension.ExtensionContext context) protected voidregisterScreenBasePackages(org.junit.jupiter.api.extension.ExtensionContext context) protected voidremoveAuthentication(org.junit.jupiter.api.extension.ExtensionContext context) resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) protected voidsetupAuthentication(org.junit.jupiter.api.extension.ExtensionContext context) protected voidsetupVaadinUi(org.junit.jupiter.api.extension.ExtensionContext context) booleansupportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) withAuthenticatedUser(String username) Sets username that should be authenticated before each test.withMainScreenId(String mainScreenId) Sets main screen id that should be opened before each test.withScreenBasePackages(String... screenBasePackages) Sets screen packages.
- 
Field Details- 
APP_UI- See Also:
 
- 
SCREEN_PACKAGES- See Also:
 
- 
authenticatedUser
- 
mainScreenId
- 
screenBasePackages
 
- 
- 
Constructor Details- 
JmixUiTestExtensionpublic JmixUiTestExtension()
 
- 
- 
Method Details- 
getAuthenticatedUser- Returns:
- username or nullif not set
 
- 
withAuthenticatedUserSets username that should be authenticated before each test. If username is not set, authentication will be performed by system user.- Parameters:
- username- username
- Returns:
- current instance
 
- 
getMainScreenId- Returns:
- main screen id or nullif not set
 
- 
withMainScreenIdSets main screen id that should be opened before each test. The screen with given id should be placed under the package provided bywithScreenBasePackages(String...).If main screen id is not set, the UiProperties.getMainScreenId()will be used.- Parameters:
- mainScreenId- main screen id
- Returns:
- current instance
 
- 
getScreenBasePackages- Returns:
- screen packages or nullif not set
 
- 
withScreenBasePackagesSets screen packages. Screens under these packages will be available in test. If packages are not set, all application screens will be available depending on the test's configuration.- Parameters:
- screenBasePackages- screen packages
- Returns:
- current instance
 
- 
beforeEach- Specified by:
- beforeEachin interface- org.junit.jupiter.api.extension.BeforeEachCallback
- Throws:
- Exception
 
- 
afterEach- Specified by:
- afterEachin interface- org.junit.jupiter.api.extension.AfterEachCallback
- Throws:
- Exception
 
- 
supportsParameterpublic boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
- supportsParameterin interface- org.junit.jupiter.api.extension.ParameterResolver
- Throws:
- org.junit.jupiter.api.extension.ParameterResolutionException
 
- 
resolveParameterpublic Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
- resolveParameterin interface- org.junit.jupiter.api.extension.ParameterResolver
- Throws:
- org.junit.jupiter.api.extension.ParameterResolutionException
 
- 
setupAuthenticationprotected void setupAuthentication(org.junit.jupiter.api.extension.ExtensionContext context) 
- 
removeAuthenticationprotected void removeAuthentication(org.junit.jupiter.api.extension.ExtensionContext context) 
- 
setupVaadinUiprotected void setupVaadinUi(org.junit.jupiter.api.extension.ExtensionContext context) 
- 
getApplicationContextprotected org.springframework.context.ApplicationContext getApplicationContext(org.junit.jupiter.api.extension.ExtensionContext context) 
- 
getStoreprotected org.junit.jupiter.api.extension.ExtensionContext.Store getStore(org.junit.jupiter.api.extension.ExtensionContext context) 
- 
getAppUI
- 
registerScreenBasePackagesprotected void registerScreenBasePackages(org.junit.jupiter.api.extension.ExtensionContext context) 
- 
openMainScreenprotected void openMainScreen(org.junit.jupiter.api.extension.ExtensionContext context) 
 
-