Working with Mockito and Eclipse

Post on 24-Jan-2015

6.381 views 4 download

description

Small presentation about using mockito on an environment where you're using eclipse as your main development tool.This shows somehow to use tdd while using eclipse that creates a bunch of code for you.

Transcript of Working with Mockito and Eclipse

hugeinc.com info@hugeinc.com 45 Main St. #220 Brooklyn, NY 11222 +1 718 625 4843

Sep 1, 2011 Working with Mockito

Agenda: 1. What is Mockito 2. Why use it 3.

Writing Tests

Fewer defects, less debugging, more confidence, better design,

and higher productivity -- Kent Beck --

State Testing: assertEquals(“joe”, user.getName())

4.

Interaction Testing: verify(mockedDao).execute(criteria)

5.

• Test Stub

• Mock object

• Test Spy

Terminology

6.

•  What we’re doing on BigShipCruises

•  Profile – a simple value object.

•  FindProfileDao – handles data access.

•  ProfileFacade – bridges requests from ws.

Mockito Examples

7.

Eclipse generates the profileFacade method

First writing the test

8.

Then you implement the method

You run the test and Bang! It fails!

9.

You run the test and it passes!

10.

Eclipse generates the profileFacade method

Checking method invocation

11.

You run the test and Bang! It fails! Again!

12.

And tests pass!

Implement the method

13.

8.4 Tests/second Unit

14.

1.8 Tests/second Integration

mockito.org Learn More:

Questions…

hugeinc.com info@hugeinc.com 45 Main St. #220 Brooklyn, NY 11222 +1 718 625 4843