Skip to content Skip to sidebar Skip to footer

Jvm Options In Android When Run Gradlew Test

I have a project that using Robolectric for unit test purpose. This project uses Robolectric 3.0 and need to add -ea and -noverify options in Virtual Machine options. In Android S

Solution 1:

It is already answered but this may be an easier solution:

In your application modules' build.gradle file in android closure, add this.

android {
  ....

  testOptions {
    unitTests.all {
      jvmArgs '-noverify'
    }
  }
}

Solution 2:

I found that we can add this block to app's build.gradle to solve this problem

tasks.whenTaskAdded { theTask ->
    def taskName = theTask.name.toString()
    if ("testDevDebug".toString().equals(taskName)) {
        theTask.jvmArgs('-ea', '-noverify')
    }
}

DevDebug is my build variant.


Solution 3:

Maybe this

 ./gradlew -Dorg.gradle.jvmargs="-ea -noverify" test

Post a Comment for "Jvm Options In Android When Run Gradlew Test"