Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Spock testing with Spring
I'm writing a Spring Boot application and recently added Vaadin to build out the UI.
My application has existing tests that make use of Spock and its mocking provisions. The trouble is, when I attempt to run my existing tests, I'm getting an error from Vaadin:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaadinServiceFactory': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No VaadinService bound to current thread
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:127)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1600)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:66)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:53)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.afterTestMethod(ResetMocksTestExecutionListener.java:48)
at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:319)
at org.spockframework.spring.SpringTestContextManager.afterTestMethod(SpringTestContextManager.java:58)
at org.spockframework.spring.SpringInterceptor.interceptCleanupMethod(SpringInterceptor.java:68)
at org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:31)
at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.IllegalStateException: No VaadinService bound to current thread
at org.vaadin.spring.context.VaadinServiceFactory.getObject(VaadinServiceFactory.java:22)
at org.vaadin.spring.context.VaadinServiceFactory.getObject(VaadinServiceFactory.java:14)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 18 more
I'm not sure what's causing this, or what I should do about it. It appears that org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks() is throwing things for a loop, but much Googling has gotten me nowhere.
Full source code for my application is available to review: https://gitlab.koehn.com/bkoehn/self-hosted-social/commit/ad4a584060b1d2bdf4ea190939b39821ae835e89
I gave up and moved all the Vaadin to a separate subproject. That way I can have Spring @Autowired stuff in my integration tests, and I can also use Vaadin. Wish that would get fixed.