tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Boynes <jboy...@apache.org>
Subject Re: Using a mock framework for testing?
Date Sun, 04 Aug 2013 17:54:39 GMT
On Jul 31, 2013, at 10:21 AM, Mark Thomas <markt@apache.org> wrote:

> On 31/07/2013 18:09, Jeremy Boynes wrote:
>> Any objection to adding a dependency on a mocking framework to aid unit testing?
>> The one I have used most is EasyMock which is Apache License 2.0.
> 
> To save repeating the details of what I have said before:
> http://markmail.org/message/io4q25hnrs2hgmxo
> 
> Since then I still haven't seen a unit test that requires the use of
> such a framework.
> 
> There are a number of mock objects in the test classes already that
> cover the most frequently required objects.

I agree with the sentiment on using the embedded server for testing, especially when dealing
with issues reported by users where it is important to reproduce them in the same way the
issue was discovered.

Where I have found mocks useful is for new work where they let you stress edge cases that
would require scaffolding to reproduce. For example, I was looking at adding tests for WebappServiceLoader
and wanted variations of the ServletContext and ClassLoader config used. For me, using EasyMock
to set that up was simpler than defining test applications in those configurations.

I'm going to go ahead and add that test with its EasyMock dependency. As I see it, it gives
us another tool we can use where it helps.

--
Jeremy


Mime
View raw message