I upgraded to Spring Boot 2.3.0.RELEASE
and my tests no longer run. IDEA comes back saying no tests were found. The maven-failsafe-plugin
says no tests were found. I tried 2.2.7.RELEASE
and I did not see the same problem.
This is a Kotlin project using JUnit 5. My tests use an abstract base class annotated with:
@ActiveProfiles(
"local",
"test",
"acceptance-test"
)
@ExtendWith(PostgresContainerExtension::class)
@Import(AcceptanceTestConfiguration::class)
@TestPropertySource(
properties = [
// A set of properties for connecting to the DB
]
)
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = [MyApplication::class]
)
The sub-classes are (mostly) annotated with:
@Execution(ExecutionMode.CONCURRENT)
Comment From: wilkinsona
Thanks for the report. It's hard to say what the cause may be from a couple of code snippets. Can you please provide a minimal sample that reproduces the problem?
Comment From: juan-palacios
I'll try and put something together in the next couple of days
Comment From: programista-zacny
Same here. I think problem may be with annotations processor. I have this test:
class TransactionsKafkaTest extends KafkaTest {
@ActiveProfiles("mocks")
public abstract class KafkaTest extends EndpointTest {
@ActiveProfiles("test")
@SpringBootTest(classes = TestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public abstract class EndpointTest {
@Configuration
@Import(ApplicationInitializer.class)
public class TestConfiguration {
@SpringBootApplication
@Import({
RedisConfiguration.class
})
public class ApplicationInitializer {
@Configuration
@Profile("!mocks")
public class RedisConfiguration {
and yet bean RedisConfiguration
is initialized...
There was no problem with Spring Boot 2.2.6.RELEASE.
Comment From: wilkinsona
@jacakk I'm not sure that's the same problem. If RedisConfiguration
is being initialised it would suggest that profile-specific beans aren't working. On the face of it, that doesn't seem to be related to tests annotated with @SpringBootTest
not running at all. To avoid this issue tracking two potentially separate problems, please open a new issue with a complete example (an entire project that we can unzip or git clone) that reproduces the problem.
Comment From: programista-zacny
That code I gave... that was a bad example because I omitted one thing: It should be:
@ActiveProfiles("profil,mocks")
public abstract class KafkaTest extends EndpointTest {
Two profiles separated by coma, it was working in Spring Boot 2.2.6 but now it's not.
I can't find this in Spring Core changelog, if it's a bug I can provide a working example in a new issue thread.
Comment From: wilkinsona
@jacakk That still doesn't match @juan-palacios's setup as far as I can see. It's almost certainly due to https://github.com/spring-projects/spring-boot/issues/19537 where we fixed a bug that prevented a profile with a comma in its name from being activated. If you want to activate profil
and mocks
you should provide two separate names:
@ActiveProfiles({"profil", "mocks"})
To avoid derailing this issue any further, if you want to follow up please do so in a separate issue or on Gitter.
Comment From: juan-palacios
This seems to get resolved when I removed some extra JUnit dependencies we had added a while ago:
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>1.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>1.5.2</version>
<scope>test</scope>
</dependency>
Not sure why Spring Boot 2.3.0.RELEASE triggers this behaviour
Comment From: mbhave
@juan-palacios As @wilkinsona suggested, could you provide a minimal sample that we can run to reproduce the issue?
Comment From: juan-palacios
I tried to create a small project but couldn't reproduce the behaviour. Not sure what else from my project I need to bring in. I'm not sure I'll have the cycles to dig into it any further, so I'm going to close this for the time being