What to test with Robolectric?

It seems to me that I fundamentally misunderstand the purpose of Robolectric. I have been struggling with it for a week now, and still receiving a new error message is considered progress. I can check out some basic things, such as static representations in an activity, but when something more complex things come into play, things just fall apart. I had to expand Robolectric to support 3 party libraries with certain parameters, Appcompat action panels and many other things that were extremely time-consuming and actually not documented anywhere, and everything is moving pretty smoothly. I am starting to think that I am using it incorrectly, and he simply should not do what I want him to do.

The general logic of the application is quite simple, so for unit test there are not so many, the most complex things are in the UI and remote API calls. Is Robolectric supposed to make unit testing for Android less painful than with JUnit because it can run on the JVM and supports several Android classes? Perhaps a black behavior panel like Espresso would be more suitable for my needs? But we use continuous integration, and Robolectric was good and easy to set up to run tests on the CI server, and I would like to save it that way.

What are you using Robolectric for? Many blog posts recommend it for "testing the activity life cycle", but since I am also completely new in the Android world, I don’t quite understand its purpose, especially since the application that I am testing is only a portrait painter, Maybe someone please give an overview of what you use Robolectric, and how you do it, preferably with code examples and explain why and how these tests are important?

+4
source share
1 answer

We use it for:

  • unit testing: all components from parsers and utils, controllers and hosts
  • / : - , ( / ).

( ):

  • ( , , , )

, , Espresso/Robotium . CI-, - Appurify.

, , , , , robolectric. . , : Android robolectric: ?

+3

All Articles