AI Briefing
KO

Banksalad publishes Android test code writing principles based on MVP architecture

·2020.02.20 09:00

Key point

Banksalad's Android team shared test code writing principles centered on Presenter logic and solutions for blind spots by applying the MVP pattern and Clean Architecture.

Details

Banksalad's Android team established test code writing principles based on the MVP pattern and Clean Architecture. Test code is mandatory for every modified feature, with a particular focus on verifying the presenting logic of the Presenter. The View is designed to be passive and is not directly tested; if logic is included in the View, either an Instrumented Test is written or the logic is refactored out into the Presenter.

Presenter Unit Test Strategy

Tests are performed by mocking the View interface and dependencies using the Mockito library. Mockito.verify is used to check whether view functions are called, Mockito.inOrder to verify the call order, and Mockito.times to verify the number of calls. This allows the Presenter's presenting logic to be tested purely, without dependence on business logic.

Resolving Blind Spots and Refactoring

To resolve the blind spot where testing view logic inside a ViewHolder is difficult due to Android package dependencies, two approaches were presented. One is writing an Instrumented Test, and the other is refactoring to move the ViewHolder's presenting logic into the Presenter. In the latter case, SaladView and SaladHandler interfaces are introduced so that the ViewHolder acts as a View implementation, and the Presenter handles the ViewHolder's logic, restructuring the code so that unit testing becomes possible.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.