java - Maven failure on spring boot test (junit 5) -
is possible run spring boot tests 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 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 run using intellij, maven build ends failure:
[warning] corrupted stdin stream in forked jvm 1. see 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
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 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 class [org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate]'. @ org.apache.maven.plugin.surefire.booterclient.output.forkclient$operationaldata.(forkclient.java:469) @ org.apache.maven.plugin.surefire.booterclient.output.forkclient.processline(forkclient.java:191) @ org.apache.maven.plugin.surefire.booterclient.output.forkclient.consumeline(forkclient.java:158) @ org.apache.maven.plugin.surefire.booterclient.output.threadedstreamconsumer$pumper.run(threadedstreamconsumer.java:87) @ java.lang.thread.run(thread.java:745)
maven surefire plugin:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.20</version> <dependencies> <dependency> <groupid>org.junit.platform</groupid> <artifactid>junit-platform-surefire-provider</artifactid> <version>1.0.0-m6</version> </dependency> </dependencies> </plugin>
intellij bundles junit5 intellij , maven using different versions.
depending on version of intellij running, executing earlier junit5
milestone release maven using.
if you're on 2017.2
, try switching junit5
dependency in pom.xml
m4
, see if solves incompatibility.
also try specifying junit-jupiter-engine:5.0.0-m4
in plugin dependency in pom.xml
junit-platform-surefire-plugin
.
i using 5.0.0-m5
way.
[update 2017-08-10]: regarding comments, using spring boot 1.5.4.release
can't like-for-like comparison.
you don't version of intellij using - assuming tests still working under intellij, version configuration target, presumably. in maven projects view or debug test output classpath , see versions in use.
spring managing lot of versions you. using spring-boot parent pom, or depending on spring-boot-starter
dependencies?
to find out going on , spring dependency pulling in junit5
dependency breaking, run
mvn dependency:tree
and go through list of dependencies , versions see have under maven.
you may find versions think have specified being overridden, , have put exclusions in pom stop that.
[update 2]: quick change - try putting junit-jupiter-engine
dependency in maven-surefire-plugin
dependency block next junit-platform-surefire-provider
:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.19.1</version> <dependencies> <dependency> <groupid>org.junit.platform</groupid> <artifactid>junit-platform-surefire-provider </artifactid> <version>1.0.0-m5</version> </dependency> <dependency> <groupid>org.junit.jupiter</groupid> <artifactid>junit-jupiter-engine</artifactid> <version>5.0.0-m5</version> </dependency> </dependencies> </plugin>
note i'm not yet on version 2.20
(and i'm still on 5.0.0-m5
) - sorry don't have time try week either.
you see if setting maven-surefire-plugin
config forkcount=0
see if gives better exception message.
you strip down project bare minimum , open jira issues maven , spring testing. changed tags on question incluide spring-boot
1 of guys might take notice. or might not, depending on luck - find more react if tweet stackoverflow url @springboot.
Comments
Post a Comment