Skip to content

Improve Quarkus testing by preventing Vaadin servlet registration. #52

@mcollovati

Description

@mcollovati

Browserless testing on Quarkus needs to mark Vaadin the test class with @QuarkusTest annotation so that all the augmentation provided by the Vaadin extension (scopes, beans, unremovables, ...) is available during test execution.

The drawback is that with @QuarkusTest, the application is started, including the servlet container and the Vaadin initialization.
With browserless testing, both are unnecessary and only slow down the execution of the tests.

After vaadin/quarkus#281 is implemented, the Quarkus browserless testing module should provide a test profile (BrowserlessTestProfile) named vaadin-browserless and a @BrowserlessQuarkusTest annotation which activates @QuarkusTest and the test profile`

@Retention(RetentionPolicy.RUNTIME)  
@Target(ElementType.TYPE)
@QuarkusTest
@TestProfile(BrowserlessTestProfile.class)
public @interface BrowserlessQuarkusTest {}

The BrowserlessTestProfile class itself should also prevent the HTTP server from being bound to any port

public class VaadinFastTestProfile implements QuarkusTestProfile {
    @Override
    public String getConfigProfile() { return "vaadin-browserless"; }
    @Override
    public Map<String, String> getConfigOverrides() {
        return Map.of("quarkus.http.host-enabled", "false");
    }
}

User tests should then use @BrowserlessQuarkusTest instead of @QuarkusTest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    Status

    Maybe

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions