Easymock 101

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites & 1 Group

    Easymock 101 - Presentation Transcript

    1. EasyMock 101 A 30 Minute Review by Matthew McCullough
    2. ❶ What Is Mocking?
    3. Are You Mocking Me? • A fake object • Allows for more modular testing • Records and verifies expectations of calls
    4. ❷ Creating A Mock
    5. IEnumeration<Short> iEnumIntfMock = EasyMock.createMock(EnumeratedAttribute.class);
    6. ❸ Expectations
    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. Expect A Call EasyMock.expect(iEnumIntfMock.getNumberOfRows() );
    9. Expect A Return EasyMock.expect(iEnumIntfMock.getNumberOfRows() ).andReturn(5);
    10. ❹ Replaying
    11. Replay • Prime the pump to walk through expected call sequence • Provide return values in same sequence • Listen to usage of call parameters
    12. Replay Kickoff EasyMock.replay(iEnumIntfMock);
    13. ❺ Using The ClassUnderTest
    14. Testing • Call all functions as you normally would • Pass in mock where injectable • Consider how mock can be passed into internal references
    15. Testing int numOfRows = iEnumIntfMock.getNumberOfRows(); Assert.assertTrue(\"Number of rows does not match\", numOfRows > 0);
    16. ❻ Verifying
    17. • Called after all operations with the mock are done • Compares the usage to the recording
    18. Verifying EasyMock.verify(iEnumIntfMock);
    19. ❼ Resources
    20. Resources • EasyMock.org • Groovy Mocking http://docs.codehaus.org/display/GROOVY/Groovy+Mocks
    SlideShare Zeitgeist 2009

    + Matthew McCulloughMatthew McCullough Nominate

    custom

    655 views, 2 favs, 0 embeds more stats

    A quick review of the EasyMock mocking (testing) fr more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 655
      • 655 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 13
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories