New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support maven-surefire-plugin version 2.21 #809

Closed
codahale opened this Issue Apr 27, 2017 · 103 comments

Comments

@codahale

codahale commented Apr 27, 2017

Overview

If any of my assertions fail, the Maven build fails with an OutOfMemoryError:

java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3332)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
	at java.lang.StringBuilder.append(StringBuilder.java:136)
	at org.apache.maven.plugin.surefire.booterclient.output.MultipleFailureException.getLocalizedMessage(MultipleFailureException.java:52)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter$CloseableCloser.run(ForkStarter.java:200)
	at org.apache.maven.surefire.shade.org.apache.maven.shared.utils.cli.CommandLineUtils$1.call(CommandLineUtils.java:282)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:626)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:279)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:243)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1077)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:907)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:785)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

Versions

  • Maven 3.5 or 3.3.9
  • org.junit.jupiter:junit-jupiter-api:5.0.0-M4
  • org.apache.maven.plugins:maven-surefire-plugin:2.20
  • org.junit.platform:junit-platform-surefire-provider:1.0.0-M4
  • org.junit.jupiter:junit-jupiter-engine:1.0.0-M4

Repro

You should be able to reproduce this yourselves by trying to run mvn test for this project/commit: codahale/shamir@0106f1b. It should have a few failed assertions (I accidentally removed a few byte casts on int literals), but instead the build errors out. I can't reproduce this via the IntelliJ runner, FWIW.

As a simpler repro case, assert 1 == 0; and this in the pom.xml seems to produce the error:

  <properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit.jupiter.version>5.0.0-M4</junit.jupiter.version>
    <junit.platform.version>1.0.0-M4</junit.platform.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.20</version>
        <configuration>
          <excludes>
            <exclude>**/generated/**</exclude>
          </excludes>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>${junit.platform.version}</version>
          </dependency>
          <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

Deliverables

@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 27, 2017

FYI: I updated the Deliverables.

@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 27, 2017

@codahale, can you possibly provide a stack trace that includes invocations from within the JUnit Platform or JUnit Jupiter?

@sbrannen sbrannen self-assigned this Apr 27, 2017

@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 27, 2017

I figured out the source of the problem.

The junit-platform-surefire-provider is not compatible with version 2.20 of the maven-surefire-plugin.

Setting the version of the maven-surefire-plugin back to 2.19.1 should allow your build to execute as expected.

Can you please confirm that this works for you?

@codahale

This comment has been minimized.

codahale commented Apr 27, 2017

Hah, I was elbow-deep in maven-surefire-plugin adding debug logging. Yes, 2.19.1 works just fine.

@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 27, 2017

Hah, I was elbow-deep in maven-surefire-plugin adding debug logging. Yes, 2.19.1 works just fine.

Great! Thanks for confirming. 👍

@sbrannen sbrannen changed the title from OOM on assertion failure with Maven/Surefire to junit-platform-surefire-provider is not compatible with maven-surefire-plugin version 2.20 Apr 27, 2017

@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 27, 2017

FYI: I have updated this issue's title accordingly.

sbrannen added a commit that referenced this issue Apr 27, 2017

Build against maven-surefire-plugin version 2.20
The junit-platform-surefire-provider is now built against version 2.20
of the maven-surefire-plugin.

Issue: #809
@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 27, 2017

As of commit cc91203, we are now building against version 2.20 of the Maven Surefire Plugin.

This will be available in 5.0 M5 as well as all upcoming SNAPSHOT builds.

@sbrannen sbrannen changed the title from junit-platform-surefire-provider is not compatible with maven-surefire-plugin version 2.20 to Support maven-surefire-plugin version 2.20 Apr 27, 2017

@sbrannen sbrannen closed this Apr 27, 2017

@smoyer64

This comment has been minimized.

Contributor

smoyer64 commented Apr 27, 2017

Hmm ... I created junit-team/junit5-samples#23 because I was starting a new project with M4 and wanted to reduce the configuration boiler-plate. I didn't realize that I would end up hitting this bug (no code or tests yet) but I guess I'll switch that project to SNAPSHOT!

@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 29, 2017

but I guess I'll switch that project to SNAPSHOT!

Let's not switch the sample projects to build against snapshots.

They are meant to align with the most current release, since that is what average developers are expected to use.

@smoyer64

This comment has been minimized.

Contributor

smoyer64 commented Apr 29, 2017

I was starting a new project with M4

I meant that I'd switch my new project that led me to create that issue to the SNAPSHOT version - not that I'd switch the junit5-maven-provider to SNAPSHOT. It does mean that junit-team/junit5-samples#23 is blocked until M5 (you can leave it assigned to me if you'd like).

It is amusing to me that this issue ended up being related.

@sbrannen

This comment has been minimized.

Member

sbrannen commented Apr 29, 2017

Aha.

Alles klar. Tutto chiaro. Everything clear. 😉

@elliotcm

This comment has been minimized.

elliotcm commented May 5, 2017

I've also experienced this issue with the same combination of versions as @codahale. Switching down to 2.19.1 also unblocks the issue. I'll chip in with verification of my project against M5 when it comes out.

@marcphilipp marcphilipp reopened this Jun 17, 2017

@marcphilipp marcphilipp modified the milestones: 5.0 M6, 5.0 M5 Jun 17, 2017

@marcphilipp

This comment has been minimized.

Member

marcphilipp commented Jun 17, 2017

We cannot update to 2.20 because it contains a critical bug that causes an OutOfMemory error (see #855 for details). This issue is blocked until #855 has been resolved with Surefire 2.20.1.

marcphilipp added a commit that referenced this issue Jun 17, 2017

@Tibor17

This comment has been minimized.

Tibor17 commented Mar 7, 2018

@marcphilipp

This comment has been minimized.

Member

marcphilipp commented Mar 7, 2018

Can you guys tell me which commit of your project was last time migrated to Surefire project?

The commit was 2f49071. You should probably take @britter's branch and apply the diff to the first commit and then apply all of his changes. Please let me know if I can help.

@sbrannen

This comment has been minimized.

Member

sbrannen commented Mar 7, 2018

@sormuras, can this issue be closed now?

@sbrannen sbrannen modified the milestones: 5.2 Backlog, 5.2 M1 Mar 7, 2018

@sormuras

This comment has been minimized.

Member

sormuras commented Mar 7, 2018

Sure. All deliverables are checked.

@sbrannen

This comment has been minimized.

Member

sbrannen commented Mar 7, 2018

Closed via commits 1b0acb9 and 782500e.

@olamy

This comment has been minimized.

olamy commented Apr 10, 2018

works perfectly here with junit-platform-surefire-provider 1.2.0-SNAPSHOT
Great job!
Any plan for a release soon?

@Tibor17

This comment has been minimized.

Tibor17 commented Apr 10, 2018

@olamy

This comment has been minimized.

olamy commented Apr 10, 2018

please do not delay too long.
It's just a pain for people who are using last surefire because of jdk10 support but cannot use junit5.
IMHO It's a VERY blocker situation!!

@Tibor17

This comment has been minimized.

Tibor17 commented Apr 11, 2018

@olamy

This comment has been minimized.

olamy commented Apr 11, 2018

@Tibor17

This comment has been minimized.

Tibor17 commented Apr 11, 2018

@Tibor17

This comment has been minimized.

Tibor17 commented Apr 11, 2018

@SaidBenaissa

This comment has been minimized.

SaidBenaissa commented Apr 11, 2018

Added this to dependencies:

org.junit.platform
junit-platform-surefire-provider
1.1.0

And this to plugins:
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
                     <version>2.19.1</version>
        </plugin>

It's will fine

@Tibor17

This comment has been minimized.

Tibor17 commented Apr 11, 2018

@Tibor17

This comment has been minimized.

Tibor17 commented Apr 11, 2018

@olamy

This comment has been minimized.

olamy commented Apr 12, 2018

@sbrannen any date for a release? At the Eclipse Jetty project we are keen to migrate to Junit5 but we are blocked by this as we want to have jdk10 build working as well with the last surefire version.

@marcphilipp

This comment has been minimized.

Member

marcphilipp commented Apr 13, 2018

@olamy We'll discuss the release timeline in the team today and update the corresponding milestones. I think we should release 5.2 sooner than originally planned so the Surefire provider is compatible with the latest Surefire release.

Andrei94 added a commit to Andrei94/junit5 that referenced this issue Jun 23, 2018

Andrei94 added a commit to Andrei94/junit5 that referenced this issue Jun 23, 2018

Andrei94 added a commit to Andrei94/junit5 that referenced this issue Jun 23, 2018

aaanders added a commit to aaanders/dropwizard that referenced this issue Sep 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment