-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Labels
type: bugA general bugA general bugtype: regressionA regression from a previous releaseA regression from a previous release
Milestone
Description
Context caching is not performed when two identically configured test classes are in different packages. For example:
package com.example.foo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class FooTests {
@Test
public void contextLoads() {
}
}
package com.example.bar;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class BarTests {
@Test
public void contextLoads() {
}
}
The context will be loaded twice due to AutoConfigurationPackages$Registrar
returning a PackageImport
for the test class from determineImports(AnnotationMetadata)
. The test classes are in different packages (com.example.foo
and com.example.bar
) so this is enough to prevent the cache keys from matching.
The problem was introduced in 1.5 as part of the changes made in fa6a138 for #7953.
brabenetz, nithril, jaric85, marekdominiak, Lord0 and 4 more
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bugtype: regressionA regression from a previous releaseA regression from a previous release