O'Reilly logo

Vaadin 7 Cookbook by Ondrej Kvasnovsky, Jaroslav Holan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit testing in an MVP pattern

Unit tests are testing code without any outside dependencies. The outside dependencies are usually mocked by framework such as, in this recipe, Mockito (https://code.google.com/p/mockito).

In this recipe, we will demonstrate testability of the MVP pattern, so we will write unit tests for the presenter and view. We will utilize the LoginPresenter, UserService, LoginView, LoginViewHandler, and LoginViewImpl classes from the Login form with Model View Presenter recipe.

Getting ready

Get the code from the Login form with Model View Presenter recipe.

How to do it...

Perform the following steps:

  1. Create the LoginViewImplTest class inside the test folder:
    public class LoginViewImplTest { }
  2. Before we start testing, we need to set ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required