Class BrowserlessTest

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

@ExtendWith(com.vaadin.browserless.BrowserlessTestExtension.class) public abstract class BrowserlessTest extends com.vaadin.browserless.BaseBrowserlessTest implements com.vaadin.browserless.TesterWrappers
Base JUnit 6 class for browserless tests. The class automatically scans the classpath for routes and error views. Subclasses should typically restrict classpath scanning to specific packages for faster bootstrap by using the ViewPackages annotation. If the annotation is not present, a full classpath scan is performed.
 
 @ViewPackages(classes = { CartView.class, CheckoutView.class })
 class CartViewTest extends BrowserlessTest {
 }

 @ViewPackages(packages = { "com.example.shop.cart", "com.example.security" })
 class CartViewTest extends BrowserlessTest {
 }

 @ViewPackages(classes = { CartView.class, CheckoutView.class }, packages = {
         "com.example.security" })
 class CartViewTest extends BrowserlessTest {
 }
 
 
The Vaadin environment lifecycle is managed by BrowserlessTestExtension, which calls BaseBrowserlessTest.initVaadinEnvironment() before each test and BaseBrowserlessTest.cleanVaadinEnvironment() after each test via virtual dispatch. When the test class is annotated with @TestInstance(TestInstance.Lifecycle.PER_CLASS), the environment is shared across all tests in the class (initialized once in @BeforeAll, torn down in @AfterAll).

To provide custom Flow service implementations via the Lookup SPI, override BaseBrowserlessTest.lookupServices():

 
 @Override
 protected Set<Class<?>> lookupServices() {
     return Set.of(CustomInstantiatorFactory.class);
 }
 
 

Note: Subclasses that override initVaadinEnvironment must NOT add @BeforeEach — the extension handles invocation via virtual dispatch.

To get a graphical ASCII representation of the UI tree on failure, add @ExtendWith(TreeOnFailureExtension.class) to the test class.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final String
     

    Methods inherited from class com.vaadin.browserless.BaseBrowserlessTest

    $, $, $view, cleanVaadinEnvironment, discoverRoutes, discoverRoutes, find, find, findInView, fireShortcut, getCurrentView, initSignalsSupport, initVaadinEnvironment, internalWrap, internalWrap, lookupServices, navigate, navigate, navigate, navigate, roundTrip, runPendingSignalsTasks, runPendingSignalsTasks, scanPackages, scanTesters, test, test

    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

    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

    • BrowserlessTest

      public BrowserlessTest()
  • Method Details

    • testingEngine

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