You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Jeremy Boynes <jb...@apache.org> on 2013/07/31 18:09:28 UTC

Using a mock framework for testing?

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.

Cheers
Jeremy


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Using a mock framework for testing?

Posted by Jeremy Boynes <jb...@apache.org>.
On Jul 31, 2013, at 10:21 AM, Mark Thomas <ma...@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


Re: Using a mock framework for testing?

Posted by Mark Thomas <ma...@apache.org>.
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.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Using a mock framework for testing?

Posted by Nick Williams <ni...@nicholaswilliams.net>.
On Jul 31, 2013, at 11:09 AM, 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.
> 
> Cheers
> Jeremy

EasyMock is fantastic. I use it for everything I do, and we're using it in Log4j 2.

Note that EasyMock depends on CGLIB and Objenesis, both Apache License 2.0.

Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org