Skip to content

docs: describe per-test Vaadin configuration for browserless tests - #6094

Open
mshabarov wants to merge 2 commits into
mainfrom
docs/browserless-test-configuration
Open

mshabarov wants to merge 2 commits into
mainfrom
docs/browserless-test-configuration

Conversation

@mshabarov

Copy link
Copy Markdown
Contributor

Summary

Browserless Test 1.2 lets a test set Vaadin application properties, feature flags, and Lookup services for one test class or one test method, with the new @BrowserlessTestConfig annotation or the matching builder methods (vaadin/browserless-test#148). Nothing in the documentation mentions it, and the Configuring the Extension table lists only withServices(...).

The feature replaces a pattern the docs never endorsed but that tests had to use: setting vaadin.experimental.* system properties in @BeforeAll and clearing them in @AfterAll. Flags set through the annotation need no development mode and write nothing into the project folder.

What changed

  • New page articles/flow/testing/browserless/test-configuration.adoc (order 46, right after JUnit 6 Extensions):
    • the annotation on a class and on a method, with the settings table for applicationProperties, featureFlags, and lookupServices;
    • the merge rules — every inherited annotation contributes, the closest declaration wins, lookup services accumulate, and a method-level annotation is rejected when BrowserlessClassExtension shares one environment across the class;
    • the programmatic surfaces: the extensions, the application context builder used by multi-user tests, and a testConfiguration() override, with the precedence between them;
    • a note that a Vaadin property from the Spring environment is applied on top by SpringServlet and therefore wins.
  • extensions.adoc — three rows for the new builder methods, and a line pointing at the new page.

Notes for the reviewer

  • vaadin/browserless-test#148 is merged but landed after the 1.2.0-rc1 tag, so it needs 1.2.0 final to ship with 25.3. Hold this pull request if the release does not pick it up. The API carries @since 25.3 in the sources.
  • The same pull request moved the services that the Spring and Quarkus integrations need from lookupServices() to frameworkLookupServices(), and deprecated lookupServices(). That is a behavior change for a test that overrides it, and belongs in the upgrade guide rather than here.
  • The page is new rather than a section of extensions.adoc, because the annotation works for plain BrowserlessTest subclasses too, and those tests never read the extensions page.

How to test

Documentation only, with inline snippets that are not compiled. The behavior matches BrowserlessTestConfig, BrowserlessConfiguration, and the configuration tests on vaadin/browserless-test main.

🤖 Generated with Claude Code

A browserless test can now set Vaadin application properties, feature
flags, and Lookup services for a single test class or test method with
@BrowserlessTestConfig, or build the same configuration in code. The
settings are scoped to the environment created for that test, so a
feature flag no longer needs development mode, a properties file in the
project folder, or a @beforeeach and @AfterEach pair to reset it.

Adds a Test Configuration page covering the annotation, the merge rules
for inherited and method-level declarations, and the programmatic
surfaces, and links to it from the extension configuration table.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mshabarov mshabarov added the target/v25.3 Automatically cherry-pick to the v25.3 branch label Sep 21, 2026
The services of the Spring and Quarkus integrations moved to
frameworkLookupServices() and are always registered, so an override of
lookupServices() adds to them rather than replacing them, and the method
is deprecated in favor of the test configuration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mcollovati
mcollovati self-requested a review September 21, 2026 08:53
}
----

A configuration built on an extension or on the application context builder wins over the class-level annotation, and loses against the method-level one. A [methodname]`testConfiguration()` override ranks differently: [methodname]`super.testConfiguration()` returns the configuration already resolved from the annotations, so whatever the override adds on top of it wins over all of them, the method-level annotation included. Build on [methodname]`super.testConfiguration()` to refine the declared configuration, and leave out the values that a test method needs to override.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A configuration built on an extension or on the application context builder wins over the class-level annotation, and loses against the method-level one

This is true only for the JUnit extension. BrowserlessApplicationContext only uses the configuration built with its own builder; it does take into account any annotation.
However, the annotation configuration can be provided explicitly by using BrowserlessConfiguration.from(...) factory method.

BrowserlessApplicationContext.create(b -> b.withViewPackages(MyView.class)
        .withConfiguration(BrowserlessConfiguration.from(getClass())));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target/v25.3 Automatically cherry-pick to the v25.3 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants