So, for my regular Android project, I have the following in AndroidManifest.xml:
<application android:name=".utilities.App" ...> .... </application>
And then I have an App class:
public class App extends Application { .... }
And then I have an Android JUnit Test project related to an Android project. Everything is fine and dandy, and I can write JUnit tests. However, I try to run code coverage using JUnit tests, and I get bloated results. The reason is because my application class is being called and initialized as if my application was really running. I don't want my custom App class to run when running JUnit tests or code coverage. Any configuration I need for JUnit tests will go through the appropriate JUnit setup() method. Is there any way to prevent it from executing my own application class or the way that any classes / methods / lines that are executed due to the creation of my application class are not taken into account to cover the code?
source share