Package com.vaadin.testbench.uiunittest
Class AbstractUIUnitTest
java.lang.Object
com.vaadin.testbench.uiunittest.AbstractUIUnitTest
- Direct Known Subclasses:
UIUnitTest
Base class for unit testing complex Vaadin Components and UIs. Mock and tear
down methods are un-implemented at this level. Extend this class to create
base class for different environments such as CDI and Spring by implementing
the methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstractUIUnitTest.QueryResult<T extends com.vaadin.server.ClientConnector>Result type for component searches. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends com.vaadin.server.ClientConnector>
AbstractUIUnitTest.QueryResult<T> Find all components of given type recursively within the given component container.<T extends com.vaadin.server.ClientConnector>
AbstractUIUnitTest.QueryResult<T> Find all components of given type recursively within the UI.abstract com.vaadin.ui.UICreate mocked Vaadin environment with blank UI without Atmosphere support.abstract voidmockVaadin(com.vaadin.ui.UI ui) Create mocked Vaadin environment with given UI without Atmosphere support.<T> TNavigate to a viewvoidPrint the component tree for debugging.abstract voidtearDown()Do clean-up of the mocked Vaadin created with mockVaadin methods.test(com.vaadin.ui.AbstractComponent component) Perform operations with the component as a user.<T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>,R extends Enum<R>>
AbstractDateFieldTester<T, R> test(com.vaadin.ui.AbstractDateField<T, R> component) Perform operations with the component as a user.<T> AbstractFieldTester<T> test(com.vaadin.ui.AbstractField<T> component) Perform operations with the component as a user.<T> AbstractMultiSelectTester<T> test(com.vaadin.ui.AbstractMultiSelect<T> component) Perform operations with the component as a user.<T> AbstractSingleSelectTester<T> test(com.vaadin.ui.AbstractSingleSelect<T> component) Perform operations with the component as a user.test(com.vaadin.ui.Button component) Perform operations with the component as a user.<T> ComboBoxTester<T> test(com.vaadin.ui.ComboBox<T> component) Perform operations with the component as a user.<T> GridTester<T> test(com.vaadin.ui.Grid<T> component) Perform operations with the component as a user.test(com.vaadin.ui.MenuBar component) Perform operations with the component as a user.test(com.vaadin.ui.TabSheet component) Perform operations with the component as a user.<T> TreeGridTester<T> test(com.vaadin.ui.TreeGrid<T> component) Perform operations with the component as a user.<T> voidUtility method that waits while condition is true.
-
Constructor Details
-
AbstractUIUnitTest
public AbstractUIUnitTest()
-
-
Method Details
-
mockVaadin
public abstract com.vaadin.ui.UI mockVaadin() throws com.vaadin.server.ServiceExceptionCreate mocked Vaadin environment with blank UI without Atmosphere support. This is enough for common use cases testing standalone server side components. Session is locked. UI and VaadinSession thread locals are set.- Returns:
- Plank mock UI instance
- Throws:
com.vaadin.server.ServiceException- See Also:
-
mockVaadin
public abstract void mockVaadin(com.vaadin.ui.UI ui) throws com.vaadin.server.ServiceException Create mocked Vaadin environment with given UI without Atmosphere support. This is makes possible to test more complex UI logic. Session is locked. UI and VaadinSession thread locals are set.- Parameters:
ui- UI instance- Throws:
com.vaadin.server.ServiceException- See Also:
-
tearDown
public abstract void tearDown()Do clean-up of the mocked Vaadin created with mockVaadin methods. This may be necessary especially if custom UI have side effects.- See Also:
-
$
public <T extends com.vaadin.server.ClientConnector> AbstractUIUnitTest.QueryResult<T> $(Class<T> clazz) Find all components of given type recursively within the UI.- Type Parameters:
T- Component type- Parameters:
clazz- Component class- Returns:
- QueryResult of components
- See Also:
-
$
public <T extends com.vaadin.server.ClientConnector> AbstractUIUnitTest.QueryResult<T> $(com.vaadin.ui.HasComponents container, Class<T> clazz) Find all components of given type recursively within the given component container.- Type Parameters:
T- Component type- Parameters:
container- Component container to searchclazz- Component class- Returns:
- QueryResult of components
- See Also:
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
public <T extends Temporal & TemporalAdjuster & Serializable & Comparable<? super T>,R extends Enum<R>> AbstractDateFieldTester<T,R> test(com.vaadin.ui.AbstractDateField<T, R> component) Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
test
Perform operations with the component as a user. E.g. if the operation fires an event as an side effect, it has isUserOriginated = true.- Parameters:
component- The component- Returns:
- Tester for operations
-
printComponentTree
public void printComponentTree()Print the component tree for debugging. This includes all components within the UI and all windows. Also notifications are printed. Indentation is used to indicate component hierarchy. -
waitWhile
Utility method that waits while condition is true. Unlocks the mocked session and returns lock after wait ends. This is useful when waiting background thread activity to complete and letting ui.access to happen.- Type Parameters:
T- Parameter type- Parameters:
param- Parameter for the predicatecondition- Boolean predicate, can be lambda expressiontimeout- Wait maximum seconds- See Also:
-