dimanche 26 juillet 2015

How to create test classes that can be used in both Android Tests and Unit Tests?

I often find myself duplicating the exact same set of test classes such as mocks or helpers for both Android Tests /androidTest and Unit Tests /test when writing tests for an application module.

For example, I have some static functions that help me set up mocks quickly in /test/MockUtils.java However, I cannot reuse this helper class in any of my AndroidTests because they do not share the same class path - /androidTest vs /test.

I've thought of creating a new module that only contains test resources. However, this idea won't fly because the Android Gradle plugin refuses to depend on an app module.

project testCommon resolves to an APK archive which is not supported as a compilation dependency.

Is there any other way to create test classes that could be reused in both Android Tests and Unit Tests?

Aucun commentaire:

Enregistrer un commentaire