Spring Boot с 3.3.4 до 3.4.5 с несколькими конфигурациями (@springboottest (classe = setupa).JAVA

Программисты JAVA общаются здесь
Anonymous
Spring Boot с 3.3.4 до 3.4.5 с несколькими конфигурациями (@springboottest (classe = setupa).

Сообщение Anonymous »

В нашем проекте у нас есть 2 установки для интеграции. Каждому из установки нужны другие контейнеры. Контейнеры были инициализированы в статическом блоке SpringbootApplication.
для объяснения проблемы: < /p>
setupa < /strong>: < /p>
@SpringBootApplication
public class SetupA {

public static void main(String[] args) {
SpringApplication.run(SetupA.class, args);
}

static {
System.out.println("============================ setup of A ====================================");
// Containers to startup for setup A
}
}
< /code>
@SpringBootTest(classes = SetupA.class)
public class BaseATest {
}
< /code>
class SetupATests extends BaseATest {

@Test
void testA() {
System.out.println("============================ executed A test ====================================");
}
}
< /code>
setupB

@SpringBootApplication
public class SetupB {

public static void main(String[] args) {
SpringApplication.run(SetupB.class, args);
}

static {
System.out.println("============================ setup of B ====================================");
// Containers to startup for setup B
}
}
< /code>
@SpringBootTest(classes = SetupB.class)
public class BaseBTest {
}
< /code>
class SetupBTests extends BaseBTest{

@Test
void testB() {
System.out.println("============================ executed B test ====================================");
}
}
< /code>
code also available at https://github.com/koenv-star/springboo ... roblem.git
Using this setup in spring boot 3.3.4 if we ran the tests of setupA we see both the statics blocks get executed:
Изображение

while in sb 3.4.5. only the static block of B gets executed:
Изображение

Why is this suddenly different?
Also, important to mention that starting the containers in a static block it was probably not the best usecase because all the static blocks ran and all the containers started but still want to know what introduced the different behavior between the SB versions.

Подробнее здесь: https://stackoverflow.com/questions/796 ... estclasses

Вернуться в «JAVA»