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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    Polls the Prometheus endpoint until done holds.
    org.openqa.selenium.WebDriver
     
    protected String
    fetch(String path)
    Fetches path from the running server and returns the body, asserting a 200.
    protected String
    Used to determine what host the test is running on.
    protected int
    Used to determine what port the test is running on.
    protected String
    Returns the URL to the root of the server, e.g.
    protected abstract String
    Gets the absolute path to the test, starting with a "/".
    protected static double
    prometheusValue(String prometheusBody, String name, String label)
    Returns the value of the first Prometheus sample line for name, optionally narrowed to one whose label set contains label, or -1.0 if absent.
    void
     
    static void
     

    Methods inherited from class com.vaadin.testbench.BrowserTestBase

    getCapabilities, getHubHostname, getRunLocallyBrowser, getRunLocallyBrowserVersion, setBrowserTestInfo

    Methods inherited from class com.vaadin.testbench.AbstractBrowserDriverTestBase

    getDriver, setDriver

    Methods 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, wrap

    Methods inherited from class java.lang.Object

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

    Methods 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

      protected abstract String 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

      protected String 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

      protected String 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:
      createDriver in interface com.vaadin.testbench.DriverSupplier
    • awaitPrometheus

      protected String awaitPrometheus(Predicate<String> done, String what, Duration timeout) throws IOException
      Polls the Prometheus endpoint until done holds. 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 for
      what - what was waited for, for the failure message
      timeout - how long to keep polling
      Returns:
      the scrape body that satisfied done
      Throws:
      IOException
    • fetch

      protected String fetch(String path) throws IOException
      Fetches path from the running server and returns the body, asserting a 200.
      Throws:
      IOException
    • prometheusValue

      protected static double prometheusValue(String prometheusBody, String name, String label)
      Returns the value of the first Prometheus sample line for name, optionally narrowed to one whose label set contains label, or -1.0 if absent.