Package com.vaadin.testbench.unit
Class SpringUIUnit4Test
java.lang.Object
com.vaadin.testbench.unit.UIUnit4Test
com.vaadin.testbench.unit.SpringUIUnit4Test
- All Implemented Interfaces:
TesterWrappers
@TestExecutionListeners(listeners=UITestSpringLookupInitializer.class,
mergeMode=MERGE_WITH_DEFAULTS)
public abstract class SpringUIUnit4Test
extends UIUnit4Test
Base JUnit 4 class for UI unit testing applications based on Spring
Framework.
This class provides functionality of the Spring TestContext Framework, in
addition to set up a mock Vaadin Spring environment, so that views and
components built upon dependency injection and AOP can be correctly be
handled during unit testing.
Usually when unit testing a UI view it is not needed to bootstrap the whole
application. Subclasses can therefore be annotated
with @
ContextConfiguration
or other
Spring Testing annotations to load only required component or to provide mock
services implementations.
@ContextConfiguration(classes = ViewTestConfig.class)
public class ViewTest extends SpringUIUnit4Test {
}
@Configuration
class ViewTestConfig {
@Bean
MyService myService() {
return new my MockMyService();
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Map<Class<?>,
Class<? extends ComponentTester>> Fields inherited from class com.vaadin.testbench.unit.UIUnit4Test
treeOnFailure
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends Component>
ComponentQuery<T>Gets a query object for finding a component inside the UI<T extends Component>
ComponentQuery<T>Gets a query object for finding a component nested inside the given component.<T extends Component>
ComponentQuery<T>Gets a query object for finding a component inside the current viewprotected void
void
fireShortcut
(Key key, KeyModifier... modifiers) Simulates a keyboard shortcut performed on the browser.Get the current view instance that is shown on the ui.void
Gets the services implementations to be used to initialized VaadinLookup
.<T extends Component>
TNavigate to the given view class if it is registered.<C,
T extends Component & HasUrlParameter<C>>
TNavigate to view with url parameter.<T extends Component>
TNavigate to view corresponding to the given navigation target with the specified parameters.<T extends Component>
TNavigate to given location string.protected static void
Simulates a server round-trip, flushing pending component changes.<T extends ComponentTester<Y>,
Y extends Component>
TWrap component in given ComponentTester.<T extends ComponentTester<Y>,
Y extends Component>
Ttest
(Y component) Wrap component with ComponentTester best matching component type.Methods inherited from class com.vaadin.testbench.unit.UIUnit4Test
printTree, testingEngine
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.testbench.unit.TesterWrappers
test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test, test
-
Field Details
-
testers
-
scanned
-
-
Constructor Details
-
SpringUIUnit4Test
public SpringUIUnit4Test()
-
-
Method Details
-
lookupServices
Gets the services implementations to be used to initialized VaadinLookup
. Default implementation returns an empty Set. Override this method to provide custom Vaadin services, such asInstantiatorFactory
,ResourceProvider
, etc.- Returns:
- set of services implementation classes, never null.
-
initVaadinEnvironment
public void initVaadinEnvironment()- Overrides:
initVaadinEnvironment
in classUIUnit4Test
-
cleanVaadinEnvironment
protected void cleanVaadinEnvironment() -
fireShortcut
Simulates a keyboard shortcut performed on the browser.- Parameters:
key
- Primary key of the shortcut. This must not be aKeyModifier
.modifiers
- Key modifiers. Can be empty.
-
getCurrentView
Get the current view instance that is shown on the ui.- Returns:
- current view
-
test
Wrap component with ComponentTester best matching component type.- Type Parameters:
T
- tester typeY
- component type- Parameters:
component
- component to get test wrapper for- Returns:
- component in wrapper with test helpers
-
test
Wrap component in given ComponentTester.- Type Parameters:
T
- tester typeY
- component type- Parameters:
tester
- test wrapper to usecomponent
- component to wrap- Returns:
- initialized test wrapper for component
-
$
Gets a query object for finding a component inside the UI- Type Parameters:
T
- the type of the component(s) to search for- Parameters:
componentType
- the type of the component(s) to search for- Returns:
- a query object for finding components
-
$
Gets a query object for finding a component nested inside the given component.- Type Parameters:
T
- the type of the component(s) to search for- Parameters:
componentType
- the type of the component(s) to search forfromThis
- component used as starting element for search.- Returns:
- a query object for finding components
-
$view
Gets a query object for finding a component inside the current view- Type Parameters:
T
- the type of the component(s) to search for- Parameters:
componentType
- the type of the component(s) to search for- Returns:
- a query object for finding components
-
roundTrip
protected static void roundTrip()Simulates a server round-trip, flushing pending component changes.
-