10.1. Why MVP?

There have been various attempts to make UI applications easier to test. Some involve making it easier to simulate user actions by adding hooks that can be called programmatically. Some host UI components in a test framework so that they can be interacted with via code. All of these efforts have their pros and cons. The biggest drawback to all of them is that they rely on instantiating the UI elements of the applications on a desktop or other such drawing surface. This makes it harder to automate and test in a server environment such as a Continuous Integration build server.

The advantage to MVP is that it removes the UI elements from the equation. By removing that very thinnest layer, which actually draws to the screen, it becomes much easier to automate testing and, therefore, much easier to integrate into a TDD process. The level of automated testing that can thus be achieved is typically much higher than if the UI is tested at the user layer. That leaves only the thinnest veneer to be validated by testers, who only need to verify that the user interface components look right and that the user input methods function as desired.

Get Code Leader: Using People, Tools, and Processes to Build Successful Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.