dagger-2-testing-demo icon indicating copy to clipboard operation
dagger-2-testing-demo copied to clipboard

Why Robolectric redefines the Application class?

Open tseglevskiy opened this issue 8 years ago • 1 comments

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?

tseglevskiy avatar Sep 05 '16 13:09 tseglevskiy

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.

darekg11 avatar May 24 '17 20:05 darekg11