0

When running unit tests in Android studio we have to add the -noverify option to the VM options in order to get out unit tests to mock out a third party library with Mockito to pass.

Option I am talking about is reached by Run > Edit Configurations. In a JUnit Run configuration there is a textbox available for VM options (which by default seems to have -ea in it).

I need to run these unit tests on a build server for a CI build. So I need to be able to supply this -noverify CM option on the command line but I do not know how to do this.

Types of things I have tried:

  • gradlew.bat test -Dnoverify

  • gradlew.bat test -Dverify:none

  • gradlew.bat test -Dverify=none

  • gradlew.bat test -noverify

  • Added org.gradle.jvmargs=-noverify to the gradle.properties

nbonbon
  • 1,660
  • 3
  • 18
  • 27

1 Answers1

1

I was able to add the following to the build.gradle in order to allow CLI runs of units tests to work:

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

Running via Android Studio, however, still requires the -noverify options to be supplied via the VM options configuration in the run configuration. Seems like this is because of a Android Studio Bug

Related Stack Overflow Question

nbonbon
  • 1,660
  • 3
  • 18
  • 27