Slow tests, Vaadin flow 25.3.1

In Vaadin 25.2.8, the tests were really, really fast—it was actually great.

The problem in version 25.3.1 is that, according to the Surfire report, the ClassGraph remains in the BLOCKED state

Setup

  • Vaadin 25.3.1, Spring Boot 4.1.1, Java 25 (Corretto 25.0.4.1)
  • browserless-test-spring, plus com.vaadin:vaadin-dev in the POM (optional)
  • About 37 test classes create their environment with BrowserlessUIContext.forComponent(...) in @BeforeEach and close it in @AfterEach (no Spring base class for those)
  • No @ViewPackages anywhere

What I found

Surefire wrote a thread dump when I cancelled the run (in target/surefire-reports/*.dump). The main thread is inside a full ClassGraph scan started by Copilot:

at com.vaadin.copilot.shaded.classgraph.ClassGraph.scan(ClassGraph.java:1609)
at com.vaadin.copilot.CopilotDebugViewRegistrar.registerDebugViews(CopilotDebugViewRegistrar.java:58)
at com.vaadin.copilot.CopilotIndexHtmlLoader.serviceInit(CopilotIndexHtmlLoader.java:51)
at com.vaadin.flow.server.VaadinService.init(VaadinService.java:279)
at com.vaadin.browserless.mocks.MockVaadinServlet.createServletService(MockVaadinServlet.kt:45)
at com.vaadin.flow.server.VaadinServlet.init(VaadinServlet.java:134)
at com.vaadin.browserless.internal.MockVaadin.setupServlet(MockVaadin.kt:187)
at com.vaadin.browserless.BrowserlessApplicationContext$Builder.buildService(BrowserlessApplicationContext.java:732)
at com.vaadin.browserless.BrowserlessApplicationContext.create(BrowserlessApplicationContext.java:140)
at com.vaadin.browserless.BrowserlessApplicationContext.forComponent(BrowserlessApplicationContext.java:204)
at com.vaadin.browserless.BrowserlessUIContext.forComponent(BrowserlessUIContext.java:268)
at <my test>.mount(...)

Workaround

Excluding Copilot from the test classpath only:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <classpathDependencyExcludes>
            <classpathDependencyExclude>com.vaadin:copilot</classpathDependencyExclude>
        </classpathDependencyExcludes>
    </configuration>
</plugin>

For now, I added this exclusion to the pom.xml, and it has allowed version “25.3.1” to run the tests at their normal speed again.

A little strange, isn’t it?

  • And I don’t see it documented in the Vaadin documentation on browserless testing either, which is what I’m using right now.

Best regards.

Hello @rucko24,

Thanks for reporting this. This is an unexpected side effect of an experimental feature in Copilot.

Copilot scans the class path on initialization to collect some information about the project and it is done in VaadinServiceInitListener. Therefore, any time VaadinServlet#init is called, scanning is executed, which causes the slowness.

We are working on a fix. Meanwhile, you can disable the Copilot in test suites via CopilotStatus.setHiddenByUser(true) or setting the system property vaadin.copilot.enable=false

Hey, buddy,

I had this property: vaadin.copilot.enable=false, but in the application—in the usual src/main/resources directory—

I need to have another one in src/test/resources, right? So that it works with that property?

Hey buddy,

I had this property: vaadin.copilot.enable=false, but in the application—in the usual src/main/resources directory—

I need to have another one in src/test/resources, right? So that it works with that property?


I tried again, but it’s not enough to just use

vaadin:
  copilot:
    enable: false

in src/test/resources/application.yml, and it’s still slow…

I think I’ll stick with the POM with the exclusion.

In 25.3 it is possible to provide configuration per single test (How to configure the Vaadin environment of a browserless test).
Unfortunately, BrowserlessUIContext.forComponent(...) is not supported at the moment.

A workaround is to have the test code wrapped into a try/finally block and setting/removing the vaadin.copilot.enable system property (e.g. System.setProperty())

mmmm

For now, I’ll continue to use this exclusion.

This applies to all tests.

<classpathDependencyExclude>com.vaadin:copilot</classpathDependencyExclude>

Most likely, browserless-test should disable Copilot by default.
I don’t see any benefit to having it enable during testing, but I might be wrong.

Hi Rubén!

May I ask, are you running your tests in production mode?

Thanks in advance!
Miguel

mmmm i don`t know…

How did it do that?

I think it was in “dev” mode.

By default it would be dev mode yes, and now I think that enabling production mode in Browserless configuration probably would not override built time dev token.

So a cleaner option that you can use if you want to keep the pom unmodified is to disable copilot for browserless tests only using

@BrowserlessTestConfig(applicationProperties = “copilot.enable=false”)

Anyways we are working in a patch already to fix your finding, Thank you!!

For the record: here’s an issue to track support for browserless configuration in forComponent as well: Support test environment configurationin Browserless(Application|UI)Context.forComponent method · Issue #277 · vaadin/browserless-test · GitHub

And here the ticket to disable Copilot by default in browserless-test Disable Copilot by default in the mock Vaadin environment · Issue #278 · vaadin/browserless-test · GitHub