@Target(value=TYPE) @Retention(value=RUNTIME) @Documented @Inherited @BootstrapWith(value=org.springframework.boot.test.autoconfigure.graphql.GraphQlTestContextBootstrapper.class) @ExtendWith(value=org.springframework.test.context.junit.jupiter.SpringExtension.class) @OverrideAutoConfiguration(enabled=false) @TypeExcludeFilters(value=GraphQlTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureJson @AutoConfigureGraphQl @AutoConfigureGraphQlTester @ImportAutoConfiguration public @interface GraphQlTest
The annotation disables full auto-configuration and instead loads only components relevant to GraphQL tests, including the following:
@Controller
RuntimeWiringConfigurer
@JsonComponent
Converter
GenericConverter
DataFetcherExceptionResolver
Instrumentation
GraphQlSourceBuilderCustomizer
The annotation does not automatically load @Component, @Service,
@Repository, and other beans.
By default, tests annotated with @GraphQlTest have a
GraphQlTester configured. For more
fine-grained control of the GraphQlTester, use
@AutoConfigureGraphQlTester.
Typically @GraphQlTest is used in combination with
@MockBean or
@Import to load any collaborators
and other components required for the tests.
To load your full application configuration instead and test via
HttpGraphQlTester, consider using
@SpringBootTest combined
with @AutoConfigureHttpGraphQlTester.
AutoConfigureGraphQlTester| Modifier and Type | Optional Element and Description |
|---|---|
Class<?>[] |
controllers
Specifies the controllers to test.
|
Class<?>[] |
excludeAutoConfiguration
Auto-configuration exclusions that should be applied for this test.
|
ComponentScan.Filter[] |
excludeFilters
A set of exclude filters which can be used to filter beans that would otherwise be
added to the application context.
|
ComponentScan.Filter[] |
includeFilters
A set of include filters which can be used to add otherwise filtered beans to the
application context.
|
String[] |
properties
Properties in form key=value that should be added to the Spring
Environment before the test runs. |
boolean |
useDefaultFilters
Determines if default filtering should be used with
@SpringBootApplication. |
Class<?>[] |
value
Specifies the controllers to test.
|
public abstract String[] properties
Environment before the test runs.@AliasFor(value="controllers") public abstract Class<?>[] value
controllers() which
can be used for brevity if no other attributes are defined. See
controllers() for details.controllers()public abstract boolean useDefaultFilters
@SpringBootApplication. By default, only
@Controller (when no explicit controllers are
defined), RuntimeWiringConfigurer, @JsonComponent,
Converter, GenericConverter, DataFetcherExceptionResolver,
Instrumentation and GraphQlSourceBuilderCustomizer beans are
included.includeFilters(),
excludeFilters()public abstract ComponentScan.Filter[] includeFilters
public abstract ComponentScan.Filter[] excludeFilters
@AliasFor(annotation=ImportAutoConfiguration.class, attribute="exclude") public abstract Class<?>[] excludeAutoConfiguration