Package com.vaadin.browserless
Class SpringBrowserlessTest
java.lang.Object
com.vaadin.browserless.BaseBrowserlessTest
com.vaadin.browserless.SpringBrowserlessTest
- All Implemented Interfaces:
TesterWrappers
@ExtendWith(org.springframework.test.context.junit.jupiter.SpringExtension.class)
@TestExecutionListeners(listeners=BrowserlessTestSpringLookupInitializer.class,
mergeMode=MERGE_WITH_DEFAULTS)
public abstract class SpringBrowserlessTest
extends BaseBrowserlessTest
implements TesterWrappers
Base JUnit 6 class for browserless testing of 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)
class ViewTest extends SpringBrowserlessTest {
}
@Configuration
class ViewTestConfig {
@Bean
MyService myService() {
return new MockMyService();
}
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidTears down mocked Vaadin.protected voidSets up the mock Vaadin Spring environment before each test.Gets the services implementations to be used to initialized VaadinLookup.protected final StringGets the name of the Test Engine that is able to run the base class implementation.Methods inherited from class com.vaadin.browserless.BaseBrowserlessTest
$, $, $view, discoverRoutes, discoverRoutes, find, find, findInView, fireShortcut, getCurrentView, initSignalsSupport, internalWrap, internalWrap, navigate, navigate, navigate, navigate, roundTrip, runPendingSignalsTasks, runPendingSignalsTasks, scanPackages, scanTesters, test, testMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.browserless.TesterWrappers
popoverFor, popoverFor, 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, test, test, test, test, test, test, test, test, test, test, test, test
-
Constructor Details
-
SpringBrowserlessTest
public SpringBrowserlessTest()
-
-
Method Details
-
testingEngine
Description copied from class:BaseBrowserlessTestGets the name of the Test Engine that is able to run the base class implementation. The Test Engine name is reported in the exception thrown when the Vaadin environment is not set up correctly.- Specified by:
testingEnginein classBaseBrowserlessTest- Returns:
- name of the Test Engine.
-
lookupServices
Description copied from class:BaseBrowserlessTestGets 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.- Overrides:
lookupServicesin classBaseBrowserlessTest- Returns:
- set of services implementation classes, never null.
-
initVaadinEnvironment
@BeforeEach protected void initVaadinEnvironment()Sets up the mock Vaadin Spring environment before each test. Runs as a@BeforeEachmethod so that it fires after all JUnit 5 extensionbeforeEachcallbacks — in particular afterSpringExtension.beforeEach(), which populates the Spring Security context for annotations such as@WithMockUser.- Overrides:
initVaadinEnvironmentin classBaseBrowserlessTest
-
cleanVaadinEnvironment
@AfterEach protected void cleanVaadinEnvironment()Description copied from class:BaseBrowserlessTestTears down mocked Vaadin.- Overrides:
cleanVaadinEnvironmentin classBaseBrowserlessTest
-