-
Nov 7th, 2004, 01:11 PM
#1
Best testing strategy: EasyMock and JMock
-
Nov 9th, 2004, 04:28 AM
#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).
-
Nov 10th, 2004, 09:28 AM
#3
I would use them both. The APIs are sufficiently different that each one feels 'better' for one scenario vs. another...
-
Nov 13th, 2004, 05:48 PM
#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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules