Results 1 to 4 of 4

Thread: Best testing strategy: EasyMock and JMock

  1. #1
    Join Date
    Aug 2004
    Posts
    107

    Default Best testing strategy: EasyMock and JMock

    Which one is best?

    dino

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Tough question.

    Spring uses EasyMock for internal Unit Testing, but I think it is a close call.

    They both allow for mocking of interfaces and classes (using, like Spring AOP, JDK dynamic proxies and CGLIB).

  3. #3
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    I would use them both. The APIs are sufficiently different that each one feels 'better' for one scenario vs. another...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  4. #4
    Join Date
    Aug 2004
    Posts
    107

    Default

    I'm starting to like the jmock. Very flexible. Way more flexible that EasyMock.

    But boy, these guys don't believe in javadoc (not a single line). What's with these guys. Are they so arogant that they don't have to document their code? I wish they would take a look at spring and see how real documentation is done (this is why I believe that pico container has not taken off. They really don't like to document their stuff).

    I do find their method calling a bit strange (not intuitive and really hacky). E.g.

    mockOrganizationDAO.expects(once()).method("getLis t").with(same(OrganizationDao.READ_ALPHA_ID_ORDERE D),
    eq(new Object[]{newOrg.getAlphaOrganizationId()})).
    will(returnValue(newOrgList));

    Is it me or is the above code not very pleasant to look at (and very difficult to code it right).

    I created my own abstraction:
    TestMethod method = new TestMethod(once(), "getList");
    method.setArguments(same(OrganizationDao.READ_ALPH A_ID_ORDERED), eq(new Object[]{newOrg.getAlphaOrganizationId()}));
    method.setReturnValue(newOrgList);
    mockOrganizationDAO.expects(method);

    Simple and clean.

    Dino

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •