简体   繁体   English

尝试使用Jacoco获得测试覆盖率时出现OutOfMemoryError

[英]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. 我有一个大约6万行代码的android项目,我们使用gradle构建应用程序并使用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. 我们最近使用了jacoco插件来获取单元测试的覆盖率数据,但是,在进行约140次测试后,其余测试开始失败,并出现OutOfMemoryError异常。

I tried to play with gradle.properties to change the heap size of JVM, but it didn't seem to help. 我尝试使用gradle.properties更改JVM的堆大小,但似乎没有帮助。

Any help will be appreciated. 任何帮助将不胜感激。 Thanks very much. 非常感谢。

Did you try the following: 您是否尝试过以下方法:

  1. Setting the following in your user's ~/.bash_profile file 在用户的〜/ .bash_profile文件中设置以下内容

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

  2. In GRADLE_HOME/bin/gradle executable (shell script) file, change the following line to: 在GRADLE_HOME / bin / gradle可执行文件(shell脚本)中,将以下行更改为:

     DEFAULT_JVM_OPTS="$JAVA_OPTS $GRADLE_OPTS" 

    The above assumes, you are setting some JAVA xxx mem variables as well 上面假设,您还要设置一些JAVA xxx mem变量

  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? 看,这有帮助吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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