Package com.vaadin.testbench.unit
Class UIUnit4Test
java.lang.Object
com.vaadin.testbench.unit.BaseUIUnitTest
com.vaadin.testbench.unit.UIUnit4Test
- All Implemented Interfaces:
TesterWrappers
- Direct Known Subclasses:
SpringUIUnit4Test
Base JUnit 4 class for UI unit tests.
The class automatically scans classpath for routes and error views.
Subclasses should typically restrict classpath scanning to a specific
packages for faster bootstrap, by using
ViewPackages annotation. If
the annotation is not present a full classpath scan is performed
invalid input: '{@code
@ViewPackages(classes = {CartView.class, CheckoutView.class})
public class CartViewTest extends UIUnit4Test {
}
@ViewPackages(packages = {"com.example.shop.cart", "com.example.security"})
public class CartViewTest extends UIUnit4Test {
}
@ViewPackages(
classes = {CartView.class, CheckoutView.class},
packages = {"com.example.security"}
)
public class CartViewTest extends UIUnit4Test {
}
</pre>
Set up of Vaadin environment is performed before each test by {@link
#initVaadinEnvironment()} method, and will be executed before {@code @Before}
methods defined in subclasses. At the same way, cleanup tasks operated by
{@link #cleanVaadinEnvironment()} are executed after each test, and after all
{@code @After} annotated methods in subclasses.
Custom Flow service implementations supported by {@link
com.vaadin.flow.di.Lookup} SPI can be provided overriding {@link
#initVaadinEnvironment()} and passing to super implementation the service
classes that should be initialized during setup.
<pre>
{@code
@Override
public void initVaadinEnvironment() {
super.initVaadinEnvironment(CustomInstantiatorFactory.class);
}
}
</pre>
<p/>
To get a graphical ascii representation of the UI tree on failure override
the {@link #printTree()} method to return true.'-
Field Summary
FieldsFields inherited from class com.vaadin.testbench.unit.BaseUIUnitTest
scanned, testers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreate mocked Vaadin core obects, such as session, servlet populated with Routes, UI etc.booleanOverride to return true to get component tree output into log on test failure.protected final StringGets the name of the Test Engine that is able to run the base class implementation.Methods inherited from class com.vaadin.testbench.unit.BaseUIUnitTest
$, $, $view, cleanVaadinEnvironment, discoverRoutes, discoverRoutes, fireShortcut, getCurrentView, initSignalsSupport, lookupServices, navigate, navigate, navigate, navigate, roundTrip, runPendingSignalsTasks, runPendingSignalsTasks, 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.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, test, test, test, test, test, test, test
-
Field Details
-
treeOnFailure
public org.junit.rules.TestRule treeOnFailure
-
-
Constructor Details
-
UIUnit4Test
public UIUnit4Test()
-
-
Method Details
-
printTree
public boolean printTree()Override to return true to get component tree output into log on test failure.- Returns:
trueto print component tree
-
initVaadinEnvironment
public void initVaadinEnvironment()Description copied from class:BaseUIUnitTestCreate mocked Vaadin core obects, such as session, servlet populated with Routes, UI etc. for testing and find testers for the components.- Overrides:
initVaadinEnvironmentin classBaseUIUnitTest
-
testingEngine
Description copied from class:BaseUIUnitTestGets 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 classBaseUIUnitTest- Returns:
- name of the Test Engine.
-