简体   繁体   English

从IntelliJ运行Robolectric测试会导致内存不足

[英]Running a Robolectric test from IntelliJ causes OutOfMemory

I am trying to run a unit test from IntelliJ that uses Robolectric by following the example here :: http://pivotal.github.com/robolectric/intellij-quick-start.html 我试图通过遵循以下示例的示例从使用Robolectric的IntelliJ运行单元测试: http: //pivotal.github.com/robolectric/intellij-quick-start.html

Have added the Robolectric jar and a jar for Junit4. 添加了Robolectric罐和Junit4的罐。 When the test runs I see the following output >> 测试运行时,我看到以下输出>>

IntelliJ输出

Have googled around and found some suggestions that I need to specify some vm args. 到处搜索,发现一些建议,我需要指定一些虚拟机参数。 This post is describing a similar issue with Eclipse java heap space The post is concerned with using Robolectric in tandem with a Maven project. 这篇文章描述了Eclipse Java堆空间的类似问题。这篇文章涉及与Maven项目一起使用Robolectric。 I have read that it is easier to use Robolectric inside a Maven project but I have elected not to do this as my Android project has no other use for Maven. 我已经读过,在Maven项目中使用Robolectric更容易,但是我选择不这样做,因为我的Android项目对Maven没有其他用途。

If anyone has any wisdom on what is wrong here it would be greatly appreciated. 如果有人对这里的错误有任何智慧,将不胜感激。

Maybe it will help. 也许会有所帮助。 You need proper local.properties file with android sdk location in the root of your project to run Robolectric correctly: 您需要在项目根目录中具有android sdk位置的正确local.properties文件,才能正确运行Robolectric:

sdk-location=c:\\Development\\android-sdk-windows
sdk.dir=c:\\Development\\android-sdk-windows

I ran into the same issue and found an answer here: https://coderwall.com/p/rcgyfq 我遇到了同样的问题,并在这里找到了答案: https : //coderwall.com/p/rcgyfq

1.- Copy the file "/Applications/IntelliJ IDEA.app/bin/idea.vmoptions" to "~/Library/Preferences/IntelliJIdea12/idea.vmoptions"
2.- Edit file "~/Library/Preferences/IntelliJIdea12/idea.vmoptions"
3.- For example change -Xmx800m by -Xmx2048m
4.- Restart IntellijIDEA 12

This stopped my Out of Memory exceptions and greatly decreased my overall test time. 这停止了​​我的内存不足异常,并大大减少了我的总体测试时间。

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

相关问题 运行时异常运行robolectric测试IntelliJ - Runtime Exception running robolectric tests IntelliJ Robolectric-Gradle插件运行单个测试 - Robolectric-Gradle plugin running single test 使用Robolectric和AppCompat运行Gradle测试会导致NullPointerException - Running Gradle test with Robolectric and AppCompat results in NullPointerException 从gradle运行Robolectric测试会给出OutOfMemoryError。 来自AndroidStudio的罚款 - Running Robolectric test from gradle gives OutOfMemoryError. Fine from AndroidStudio MultiDexApplication的使用导致Application类的Robolectric测试中断 - Usage of MultiDexApplication causes Robolectric test for the Application class to break 无法从Robolectric 2单元测试中创建ActionBarActivity - Cannot create ActionBarActivity from Robolectric 2 unit test Robolectric测试从小部件启动的活动 - Robolectric Test an activity launched from a widget Robolectric PowerMock运行测试时出现java.lang.NoClassDefFoundError错误 - Robolectric PowerMock java.lang.NoClassDefFoundError error while running a test intellij + gradle + robolectric +浓缩咖啡 - intellij + gradle + robolectric + espresso Robolectric测试未针对具有自己的Application类的项目运行 - Robolectric test not running for project having own Application class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM