简体   繁体   中英

OutOfMemoryError when trying to get test coverage with Jacoco

I have an android project that is about 60K lines of code, and we use gradle to build the app and run unit test with robolectric. We recently applied jacoco plugin to get the coverage data for unit testing, however, after about 140 tests, the rest of tests started failing with OutOfMemoryError exceptions.

I tried to play with gradle.properties to change the heap size of JVM, but it didn't seem to help.

Any help will be appreciated. Thanks very much.

Did you try the following:

  1. Setting the following in your user's ~/.bash_profile file

    export GRADLE_OPTS="-XX:MaxPermSize=512m"

  2. In GRADLE_HOME/bin/gradle executable (shell script) file, change the following line to:

     DEFAULT_JVM_OPTS="$JAVA_OPTS $GRADLE_OPTS" 

    The above assumes, you are setting some JAVA xxx mem variables as well

  3. Include parallel forks etc..

      test { maxParallelForks = 5 forkEvery = 50 ignoreFailures = true // Send HTML reports and xml results files to a custom user defined folder instead of default testReportDir = file("$buildDir/reports/tests/UnitTests") testResultsDir = file("$buildDir/test-results/UnitTests") testLogging.showStandardStreams = true onOutput { descriptor, event -> logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message ) } 

    }

See, if this helps?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM