EasyMock 101

4,241
-1

Published on

A quick review of the EasyMock mocking (testing) framework and how it can make your testing more productive and less tightly coupled.

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,241
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
118
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

EasyMock 101

  1. 1. EasyMock 101 A 30 Minute Review by Matthew McCullough
  2. 2. ❶ What Is Mocking?
  3. 3. Are You Mocking Me? • A fake object • Allows for more modular testing • Records and verifies expectations of calls
  4. 4. ❷ Creating A Mock
  5. 5. IEnumeration<Short> iEnumIntfMock = EasyMock.createMock(EnumeratedAttribute.class); </Short> <p> <strong> Slide 6:</strong>❸ Expectations </p> <p> <strong> Slide 7:</strong> Expecting A Lot • Expect method is called on mock • Expect sequence of method calls on mock (call createStrictMock()) • Expect parameters to methods calls on mock </p> <p> <strong> Slide 8:</strong> Expect A Call EasyMock.expect(iEnumIntfMock.getNumberOfRows() ); </p> <p> <strong> Slide 9:</strong> Expect A Return EasyMock.expect(iEnumIntfMock.getNumberOfRows() ).andReturn(5); </p>
  6. 6. ❸ Expectations
  7. 7. Expecting A Lot • Expect method is called on mock • Expect sequence of method calls on mock (call createStrictMock()) • Expect parameters to methods calls on mock
  8. 8. Expect A Call EasyMock.expect(iEnumIntfMock.getNumberOfRows() );
  9. 9. Expect A Return EasyMock.expect(iEnumIntfMock.getNumberOfRows() ).andReturn(5);

×