'Spring boot : failed to load context in integration test

When I start my integration test I have this issue:

22-02-2022 11:35:59.744 [main] INFO  o.s.d.r.c.RepositoryConfigurationDelegate.registerRepositoriesIn - Finished Spring Data repository scanning in 297ms. Found 18 JPA repository interfaces.
22-02-2022 11:35:59.942 [main] ERROR o.s.boot.SpringApplication.reportFailure - Application run failed
java.lang.NullPointerException: null
    at org.springframework.cloud.context.scope.GenericScope.setSerializationId(GenericScope.java:292)
    
    

bellow the code used for my test:

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@ActiveProfiles("it")
public abstract class BaseTest {

}


Solution 1:[1]

Try to remove the abstract from your test. Also, you probably don't need that amount of annotations. Try something like:

@SpringBootTest
@RunWith(SpringRunner.class)
public class BaseTest {

}

Use the @DirtiesContext only on specifics methods, not on the entire class. After finishing all your tests try to find the ones who dirties the context and use the @DirtiesContext on them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nalbert Wattam