When it comes to creating high quality apps testing is imperative. The primary reason for testing an app is to make it reliable. If you won’t test your app neither will your users. High quality app is the first factor that should be taken care when the coding starts. Testing is a continuous process and should be started when the development begins.
Types of testing:
There are two types of testing.
- Black box testing
2. White box testing
In black box testing we test the overall functionality of the app without having the knowledge of internal details for example, does the app publish content as its supposed to based on the requirements.
In case of white box testing we do unit testing and integration testing. White box testing test a specific piece of the code. The implementation details are well known and the behaviour is monitored. Unit tests are common which test the specific piece of code there are many tools available for this like mockito and robolectric for android apps.
We will discuss Mockito 2. It creates mocks. Artificial way of some events occurring. It has a good learning curve. The syntax is easy. The ideal test should be very high in quantity and should run really fast. For UI testing you should use Espresso. In mockito we can mock classes and call functions which work to give us an idea with the parameters passed that how will the task be carried out.the interactions are monitored. The after and other annotations get the job done efficiently. You can mock concrete classes as well as interfaces. The @Mock annotation syntax is easy and intuitive.
We can also verify the order of the interaction which helps deal with intricacies and step by step dealing with logic simplifies the process. It also supports exact number of times a function should be called or at least minimum time.
Testing is crucial when comes to quality of an application. It is imperative that we use unit tests and integration tests as well. Mockito 2 is a great framework. You can create mocks and shadow classes to write tests and run them so fast. The results are staggering because you can run all the tests simultaneously, this will detect bugs and when we add new features it is imperative to test the functionality of the complete app so that version control and configuration management can be deployed.