vendredi 28 juillet 2017

Maven failure on spring boot test (junit 5)

Is it possible to run spring boot tests with junit 5 using maven? I'm using spring boot 2.0.0.M3, junit 5.0.0-M6, maven 3.5.0. Other junit5 tests (without spring context) works.

There is simple controller:

@Controller
public class HomeController {
    @GetMapping("/")
    String home() {
        return "home";
    }
}

and test:

@ExtendWith(SpringExtension.class)
@WebMvcTest(HomeController.class)
@Import(SecurityConfig.class)
class HomeControllerTest {

    @Autowired
    private MockMvc mvc;

    @Test
    void shouldReturnHomeTemplate() throws Exception {
        this.mvc.perform(get("/").accept(MediaType.TEXT_HTML))
            .andExpect(status().isOk())
            .andExpect(content().string(startsWith("<!DOCTYPE html>")));
    }
}

Everything works when I run it using intellij, but maven build ends with failure:

[WARNING] Corrupted stdin stream in forked JVM 1. See the dump file somePath/target/surefire-reports/2017-07-28T13-50-15_071-jvmRun1.dumpstream

--debug flag shows:

java.lang.OutOfMemoryError: Java heap space

Inside 2017-07-28T13-50-15_071-jvmRun1.dumpstream I can find ~100 same exceptions (one per spring log):

Corrupted stdin stream in forked JVM 1. Stream '13:50:15.914 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command '13:50:15.914 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]'.
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:469)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:191)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:158)
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:87)
at java.lang.Thread.run(Thread.java:745)

Aucun commentaire:

Enregistrer un commentaire