ecgreb / dagger-2-testing-demo

Sample Android application using Dagger 2, Robolectric, and Mockito
85 stars 13 forks source link

Why Robolectric redefines the Application class? #2

Open tseglevskiy opened 8 years ago

tseglevskiy commented 8 years ago

I run tests. It works, and Robolectric uses the TestMyApplication class. I can not find the place where it is declared. Could you describe, why tests use TestMyApplication instead MyApplication?

darekg11 commented 7 years ago

If anybody is wondering, Robolectric automatically picks up any Test predefined Application.
See docs:
http://robolectric.blogspot.com/2013/04/the-test-lifecycle-in-20.html

Especially: That will cause a class called com.myapp.Application to be loaded. However, if you create a class with the same name and package, but with "Test" prepended to the class name, Robolectric will load that instead.