I've used easy mock 2.0 before and it seems the best available mock
framework. I'm not sure how you had problems with implementation
changes: the mock objects are meant to be the fake implementation of
an interface, so I'm not sure which implementation you are changing :)
However, I was referring to the plugin testing harness which mustn't
be used in the assembly plugin any more. IT has some problems, but it
provides a set of stubs that can be used (other plugins still use it
if you want to take a look).
Like I said, this stuff needs work and unificiation, which is
something I hope to take on in the next month.
- Brett
On 31/05/2007, at 3:34 PM, Shane Isbell wrote:
I did look through the maven-assembly-plugin module. They are using
easymock
for their unit tests. EasyMock version 2.2 requires JUnit4, so we
can't use
it. EasyMock version 2.0 is the highest we can use with Maven and
JUnit 3.
If we go this route, we would also need the class extension, which
allows
you to create mock objects from classes, as opposed to interfaces.
http://www.easymock.org/EasyMock2_0_Documentation.html
The testing harness that maven-assembly-plugin module uses looks to
be for
functional tests, not unit tests. My experience in the past with
EasyMock is
that when I changed my implementation (but still had the same public
behavior on the interface) all my tests broke. Of course, I may not
have
been using easy mock correctly. Anybody on the list have experience
with
EasyMock (or competitors)?
Shane
On 5/30/07, Brett Porter <[EMAIL PROTECTED]> wrote:
There is a plugin testing harness for this specific reason. As I
said, it's an area that needs active work in Maven.
- Brett
On 31/05/2007, at 2:39 PM, Shane Isbell wrote:
> The problem that I encountered on writing unit tests was that a lot
> of the
> classes have uninitialized fields that plexus injects with values
> during run
> time. I didn't want to start a plexus container (because then I am
> testing
> more than one method); so I had to rely on stubs to do testing. One
> idea
> that crossed my mind was either finding or writing a small
utility for
> injecting fields for unit tests. I think that this would alleviate
> some of
> the problems with having to generate a lot of stubs. I did try
> using mock
> objects but constructing the tests required knowing a fair amount
> of the
> implementation details, which in itself can become a serious
> maintenance
> issue.
>
> Shane
>
> On 5/30/07, Brett Porter <[EMAIL PROTECTED]> wrote:
>>
>>
>> On 30/05/2007, at 5:05 PM, Evan Worley wrote:
>>
>> > Does anyone know of any documentation as to best practices
for unit
>> > testing maven plugins? It seems to be an inherently
difficult task
>> > and I imagine it would require complex sets of mock objects.
Any
>> > advice or examples in this area would be appreciated.
>>
>> We're working on improving the situation there - there are some
>> testing tools already but no write ups on how to use them. I'm
told
>> the assembly plugin is the best example to work from.
>>
>> - Brett
>>