Excluding Robolectric tests from Android Studio

  android, android-studio, gradle

I am using Hilt within my application at the moment. It’s currently not possible to run Hilt/Robolectric tests using the default Android Studio "run tests" function. However it’s very convenient to be able to use it to run the rest of my suite.

How can I exclude certain tests from being run within Android Studio but still run my Robolectric tests from the Gradle command line?

Example solutions I would be interested in:

  • A separate test folder for Robolectric tests, however I couldn’t see a good solution to this similar problem
  • Annotations for Robolectric tests. Is there a way within Gradle to ignore @Ignore?

Source: Android Questions

LEAVE A COMMENT