Announcement Announcement Module
Collapse
No announcement yet.
Best testing strategy: EasyMock and JMock Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best testing strategy: EasyMock and JMock

    Which one is best?

    dino

  • #2
    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).

    Comment


    • #3
      I would use them both. The APIs are sufficiently different that each one feels 'better' for one scenario vs. another...

      Comment


      • #4
        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

        Comment

        Working...
        X