Class SpringBrowserlessTest

java.lang.Object
com.vaadin.browserless.BaseBrowserlessTest
com.vaadin.browserless.SpringBrowserlessTest
All Implemented Interfaces:
com.vaadin.browserless.TesterWrappers

@ExtendWith({org.springframework.test.context.junit.jupiter.SpringExtension.class,com.vaadin.browserless.BrowserlessTestConfigExtension.class}) @TestExecutionListeners(listeners=BrowserlessTestSpringLookupInitializer.class, mergeMode=MERGE_WITH_DEFAULTS) public abstract class SpringBrowserlessTest extends com.vaadin.browserless.BaseBrowserlessTest implements com.vaadin.browserless.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();
     }
 }
 
 
Since:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new browserless Spring test.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected Set<Class<?>>
     
    protected void
    Sets up the mock Vaadin Spring environment before each test.
    protected final String
     

    Methods inherited from class com.vaadin.browserless.BaseBrowserlessTest

    $, $, $view, allLookupServices, allLookupServices, discoverRoutes, discoverRoutes, find, find, findInView, fireShortcut, getCurrentView, getExecutedJavaScript, initSignalsSupport, internalWrap, internalWrap, lookupServices, navigate, navigate, navigate, navigate, reload, reload, roundTrip, runPendingSignalsTasks, runPendingSignalsTasks, scanPackages, scanTesters, test, test, testConfiguration

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.browserless.TesterWrappers

    activateTesterContext, 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, test, test, test, test, test, test, test, test, test, test, test, test, test, test
  • Constructor Details

    • SpringBrowserlessTest

      public SpringBrowserlessTest()
      Creates a new browserless Spring test.
  • Method Details

    • testingEngine

      protected final String testingEngine()
      Specified by:
      testingEngine in class com.vaadin.browserless.BaseBrowserlessTest
    • frameworkLookupServices

      protected Set<Class<?>> frameworkLookupServices()
      Overrides:
      frameworkLookupServices in class com.vaadin.browserless.BaseBrowserlessTest
    • initVaadinEnvironment

      @BeforeEach protected void initVaadinEnvironment()
      Sets up the mock Vaadin Spring environment before each test. Runs as a @BeforeEach method so that it fires after all JUnit 5 extension beforeEach callbacks — in particular after SpringExtension.beforeEach(), which populates the Spring Security context for annotations such as @WithMockUser.
      Overrides:
      initVaadinEnvironment in class com.vaadin.browserless.BaseBrowserlessTest
    • cleanVaadinEnvironment

      @AfterEach protected void cleanVaadinEnvironment()
      Overrides:
      cleanVaadinEnvironment in class com.vaadin.browserless.BaseBrowserlessTest