Skip to content

java.lang.IllegalStateException with @NestedTestConfiguration #28611

Closed as not planned
@sergey-morenets

Description

@sergey-morenets

Hi

I tried to use @NestedTestConfiguration as described in the Spring documentation. So this is the original test class that works properly:

@SpringJUnitConfig(AppConfig.class)
@TestPropertySource(properties = { "db.port=7000", "db.name=local" })
public class ServerTest {

	@Nested
	@TestPropertySource(properties = "db.port=8000")
	public class ServerLoadConfiguration {

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

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions