You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then I want to override my Spring configuration in the inner class and I try to put @NestedTestConfiguration(EnclosingConfiguration.OVERRIDE) either on ServerLoadConfiguration class or ServerTest class, but in both cases I always get an exception:
Caused by: java.lang.IllegalStateException: Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to load an ApplicationContext from [MergedContextConfiguration@5ef6ae06 testClass = ServerTest.ServerLoadConfiguration, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{db.port=8000}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]].
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:255)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:123)
Spring version: 6.0.0-M4
The text was updated successfully, but these errors were encountered:
If you declare @NestedTestConfiguration(OVERRIDE), none of your Spring configuration (annotations) will be inherited from the enclosing class.
In your concrete example, you specify AppConfig.class as the configuration class via @SpringJUnitConfig, but you don't have any @ContextConfiguration or @SpringJUnitConfig annotation declared on ServerLoadConfiguration.
That's why you see classes = '{}' in the MergedContextConfiguration in the exception message.
If you want to inherit the configuration classes and only override the test properties, you should be able to achieve that as follows:
Hi
I tried to use
@NestedTestConfiguration
as described in the Spring documentation. So this is the original test class that works properly:Then I want to override my Spring configuration in the inner class and I try to put
@NestedTestConfiguration(EnclosingConfiguration.OVERRIDE)
either onServerLoadConfiguration
class orServerTest
class, but in both cases I always get an exception:Spring version: 6.0.0-M4
The text was updated successfully, but these errors were encountered: