簡體   English   中英

嘗試使用Jacoco獲得測試覆蓋率時出現OutOfMemoryError

[英]OutOfMemoryError when trying to get test coverage with Jacoco

我有一個大約6萬行代碼的android項目,我們使用gradle構建應用程序並使用robolectric運行單元測試。 我們最近使用了jacoco插件來獲取單元測試的覆蓋率數據,但是,在進行約140次測試后,其余測試開始失敗,並出現OutOfMemoryError異常。

我嘗試使用gradle.properties更改JVM的堆大小,但似乎沒有幫助。

任何幫助將不勝感激。 非常感謝。

您是否嘗試過以下方法:

  1. 在用戶的〜/ .bash_profile文件中設置以下內容

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

  2. 在GRADLE_HOME / bin / gradle可執行文件(shell腳本)中,將以下行更改為:

     DEFAULT_JVM_OPTS="$JAVA_OPTS $GRADLE_OPTS" 

    上面假設,您還要設置一些JAVA xxx mem變量

  3. 包括平行叉等。

      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 ) } 

    }

看,這有幫助嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM