Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

Add default VM options to test runs #35

Open
wesleym opened this issue Jan 2, 2015 · 6 comments
Open

Add default VM options to test runs #35

wesleym opened this issue Jan 2, 2015 · 6 comments

Comments

@wesleym
Copy link

wesleym commented Jan 2, 2015

I have a project set up with android-unit-test and android-studio-unit-test-plugin. When I right-click on a Robolectric test class and run it as a JUnit test, the test fails with a VerifyError. See robolectric/robolectric#1186.

The current workaround is to add -noverify as a VM argument. I've been able to do this with the following block in my build.gradle file. When I run tests on the command line (./gradlew test), the tests work properly.

androidUnitTest {
    testTasks {
        all {
            jvmArgs '-noverify'
        }
    }
}

This configuration doesn't translate to the automatically generated run configurations in Android Studio when I run a single test class. I also haven't had any luck modifying the default JUnit configuration in the Edit Configurations dialog. Instead, my workaround is to try to run a test, modify the automatically generated run configuration to add -noverify to the VM options, then run the test again.

As a feature request, I'd like a way to set default VM options to be added to every test run.

@niedzielski
Copy link

I seem to be able to set the VM options in the Run/Debug Configurations dialog fine but they reset whenever the project syncs / reloads.

@evant
Copy link
Owner

evant commented Jan 15, 2015

Yep, that's an issue. Maybe a quick way to solve this would be to detect and change only the generated java options instead of blowing them away. Even better would be to read the gradle config, but I'm not sure that's possible since as far as I know, there is no way to pass it to the IDE using the standard android model.

@chalup
Copy link

chalup commented Jan 15, 2015

Can you just add -noverify option by default to work around the Java 1.7 +
robolectric issues?
On Jan 15, 2015 7:21 PM, "Evan Tatarka" [email protected] wrote:

Yep, that's an issue. Maybe a quick way to solve this would be to detect
and change only the generated java options instead of blowing them away.
Even better would be to read the gradle config, but I'm not sure that's
possible since as far as I know, there is no way to pass it to the IDE
using the standard android model.


Reply to this email directly or view it on GitHub
#35 (comment)
.

@evant
Copy link
Owner

evant commented Jan 15, 2015

I don't feel comfortable hard-coding that option since it really shouldn't be something you should be passing all the time. I think making it possible to specify it yourself should be good enough and more flexible.

@mttmllns
Copy link

+1 to not blowing away custom VM options. We run into OutOfMemory issues with our tests so need to tweak -Xms, -Xmx, -XX:MaxPermSize, etc. I also want to check the run configuration into source control for all our devs.

@Heinerion
Copy link

Is there any way to programmatically check, if -noverify is set on the VM?

I thought it would be useful for other as well, so I asked the question on StackOverflow

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants