Class AbstractIT
java.lang.Object
com.vaadin.testbench.AbstractBrowserTestBase
com.vaadin.testbench.AbstractBrowserDriverTestBase
com.vaadin.testbench.BrowserTestBase
com.vaadin.observability.tests.common.AbstractIT
- All Implemented Interfaces:
com.vaadin.testbench.DriverSupplier,com.vaadin.testbench.HasDriver,com.vaadin.testbench.HasElementQuery,com.vaadin.testbench.HasSearchContext,com.vaadin.testbench.HasTestBenchCommandExecutor
public abstract class AbstractIT
extends com.vaadin.testbench.BrowserTestBase
implements com.vaadin.testbench.DriverSupplier
Base class for Observability Kit integration tests. Spins up a headless
Chrome driver (or connects to a hub when configured) and navigates to the
view under test before each test method.
-
Field Summary
Fields inherited from class com.vaadin.testbench.BrowserTestBase
screenshotOnFailureExtension -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringawaitPrometheus(Predicate<String> done, String what, Duration timeout) Polls the Prometheus endpoint untildoneholds.org.openqa.selenium.WebDriverprotected StringFetchespathfrom the running server and returns the body, asserting a 200.protected StringUsed to determine what host the test is running on.protected intUsed to determine what port the test is running on.protected StringReturns the URL to the root of the server, e.g.protected abstract StringGets the absolute path to the test, starting with a "/".protected static doubleprometheusValue(String prometheusBody, String name, String label) Returns the value of the first Prometheus sample line forname, optionally narrowed to one whose label set containslabel, or-1.0if absent.voidsetup()static voidMethods inherited from class com.vaadin.testbench.BrowserTestBase
getCapabilities, getHubHostname, getRunLocallyBrowser, getRunLocallyBrowserVersion, setBrowserTestInfoMethods inherited from class com.vaadin.testbench.AbstractBrowserDriverTestBase
getDriver, setDriverMethods inherited from class com.vaadin.testbench.AbstractBrowserTestBase
assertEquals, blur, checkLogsForErrors, checkLogsForErrors, clickElementWithJs, clickElementWithJs, concatUrl, drag, dragAndDrop, dragElementOver, executeScript, findElement, findElements, getCommandExecutor, getContext, getLogEntries, getScrollX, getScrollY, hasCssClass, isElementPresent, scrollBy, scrollIntoViewAndClick, scrollToElement, testBench, waitForDevServer, waitForElementNotPresent, waitForElementPresent, waitForElementVisible, waitUntil, waitUntil, waitUntilNot, waitUntilNot, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.testbench.HasElementQuery
$, $
-
Constructor Details
-
AbstractIT
public AbstractIT()
-
-
Method Details
-
setupClass
@BeforeAll public static void setupClass() -
setup
@BeforeEach public void setup() -
getTestPath
Gets the absolute path to the test, starting with a "/".- Returns:
- the path to the test, appended to
getRootURL()for the full test URL.
-
getRootURL
Returns the URL to the root of the server, e.g. "http://localhost:8080".- Returns:
- the URL to the root
-
getDeploymentPort
protected int getDeploymentPort()Used to determine what port the test is running on.- Returns:
- the port the test is running on, by default 8080
-
getDeploymentHostname
Used to determine what host the test is running on.- Returns:
- the host name of the deployment
-
createDriver
public org.openqa.selenium.WebDriver createDriver()- Specified by:
createDriverin interfacecom.vaadin.testbench.DriverSupplier
-
awaitPrometheus
protected String awaitPrometheus(Predicate<String> done, String what, Duration timeout) throws IOException Polls the Prometheus endpoint untildoneholds. The in-browser collector flushes on a timer and on recovery, so its samples arrive shortly after the browser produced them rather than synchronously.- Parameters:
done- the condition on the scrape body to wait forwhat- what was waited for, for the failure messagetimeout- how long to keep polling- Returns:
- the scrape body that satisfied
done - Throws:
IOException
-
fetch
Fetchespathfrom the running server and returns the body, asserting a 200.- Throws:
IOException
-
prometheusValue
Returns the value of the first Prometheus sample line forname, optionally narrowed to one whose label set containslabel, or-1.0if absent.
-