Latest Android Studio/Gradle 4.2+ Updates Break Unit Tests

Viewed 105

After upgrading to gradle 4.2 and AS 4.2 (and now 4.2.1), all my unit tests started failing.

It is a bizarre case because Jenkins--which would report unit test failures--builds my project fine.

And Github--which would also fail CI--reports that there are no issues. However, I cannot successfully run my unit tests via Android Studio.

The error on the unit tests is

kotlin.UninitializedPropertyAccessException: lateinit property has not been initialized

The unit tests are pretty basic, looks like this

class ResponseTest {

   private lateinit var response: Response

   @Before
   fun setUp() {
      response = Constants.RESPONSE_PATH.getDataFromGson()
   }

   ....
}

I omitted the actual tests since the error references the lateinit var. I do not believe the error can be trusted. Because rolling back AS/gradle to 4.1.3 everything works as expected.

Are there additional steps for getting unit tests to work in 4.2?

0 Answers
Related