Skip to content

Imports on a containing test class are ignored when a nested class has imports #49860

@wilkinsona

Description

@wilkinsona

This was discovered as part of #49854.

This fails:

@WebMvcTest
class ExampleTests {

	@Autowired
	MockMvcTester mvc;

	@Nested
	@Import(Blank.class)
	class NestedExample {

		@Test
		void contextLoads() {

		}


	}
	
	static class Blank {
		
	}

}

@SpringBootTest is also affected:

@SpringBootTest
@AutoConfigureMockMvc
class ExampleTests {

	@Autowired
	MockMvcTester mvc;

	@Nested
	@Import(Blank.class)
	class NestedExample {

		@Test
		void contextLoads() {

		}


	}
	
	static class Blank {
		
	}

}

In either case, the problem doesn't occur if @Import(Blank.class) is removed or if it's moved out onto the containing class.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions