January 2018
Intermediate to advanced
434 pages
14h 1m
English
When you run the unit tests, they test all the methods that have the @Test notation above them. There is also a @Before notation, which is placed above a method. The method with the @Before notation is run before any other method of the class. This can be helpful when you are setting up objects and variables that might be used later.
One thing to note here is that unit tests cannot use Android SDK components. To use those components, you need instrumentation tests, or use a mocking framework like Mockito, which mocks the Android components so that it can be used unit tests. We will cover this in the next recipe.
Read now
Unlock full access