Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

Why do you put Robolectric tests (data-test) in a different module?

Open fernandocamargoai opened this issue 11 years ago • 8 comments

Why did you just created the /src/test/java inside :data?

fernandocamargoai avatar Apr 27 '15 23:04 fernandocamargoai

Because it is the only way to set it up. If you check the module, is a pure java module and not an android one.

android10 avatar Apr 28 '15 21:04 android10

@android10, is it a specific problem with an Android Library Project? I'm planning to implement Unit Tests + Espresso in my presentation layer. Will I need to create a 'presentation-test' module? I'll try to use /src/test/java inside :presentation first. If it works, you'll comment here.

fernandocamargoai avatar Jul 06 '15 22:07 fernandocamargoai

This was due to the robolectric 2+ setup that needed some hacks in order to make it work. There was not any unit test support back then.

android10 avatar Jul 07 '15 20:07 android10

Understood. So, in the current version of Robolectric and Android Studio, it'd be possible, right?

Anyway, I'm still using separate modules for the data and presentation because of this issue:

https://bitbucket.org/hvisser/android-apt/issues/22/dagger-robolectric-gradle-apt-source-not

I like to use Dagger to inject my tests and the Android APT isn't generating source for 'test' source. With separate module, I'm using the plugin the gradle-apt-plugin, wich makes the Dagger to work nicely with tests.

fernandocamargoai avatar Jul 08 '15 18:07 fernandocamargoai

@fernandocamargoti all data unit tests put inside src/test. No need to use a separate module now. Here is the changeset: https://github.com/android10/Android-CleanArchitecture/commit/317dd33f93fd1fd92378474d6a530c328628ce3d

android10 avatar Jul 08 '15 21:07 android10

It's nice, @android10. I'll migrate as soon as that Android APT's bug is fixed, since I'm using Dagger to inject my tests.

fernandocamargoai avatar Jul 09 '15 10:07 fernandocamargoai

@android10 Why presenter tests are not written using robolectric to avoid need to virtual device?

dharmendrainnovify avatar Jul 14 '17 10:07 dharmendrainnovify

@dharmendrainnovify if there are no android dependencies, there is no need to use Robolectric.

android10 avatar Jul 14 '17 16:07 android10