Class SpyFieldsSupport

java.lang.Object
ru.vyarus.dropwizard.guice.test.jupiter.env.field.AnnotatedTestFieldSetup<SpyBean,Object>
ru.vyarus.dropwizard.guice.test.jupiter.ext.spy.SpyFieldsSupport
All Implemented Interfaces:
TestExecutionListener, TestEnvironmentSetup

public class SpyFieldsSupport extends AnnotatedTestFieldSetup<SpyBean,Object>
SpyBean test fields support implementation.

Annotated fields resolved in time of guicey extension initialization (beforeAll or beforeEach). Register aop interceptor around target service to intercept all calls, and redirect all calls through spy object. This way, real bean becomes spied and still injected everywhere.

Manual values are not supported: @MockBean should be used instead.

In beforeAll injects static values, in beforeEach inject both (in case if beforeAll wasn't called). Calls spies reset after each test.

Since:
10.02.2025