You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Dawson Mossman <da...@bulletproofsi.com> on 2005/03/09 15:00:50 UTC

Mock objects with Cactus

Hi Vincent,
I am fairly new to Cactus and am trying to understand exactly how it
should work.  

Our organization wants to perform code logic unit testing and
integration testing (we'll worry about functional testing later).  For
our code logic unit testing, we are planning on doing JUnit tests with
Mock objects.  

This is the strategy I am thinking we could use:
1) As we develop individual classes we will write JUnit tests using Mock
objects to test class methods.
2) Then, as we begin to integrate components (classes), we will take the
existing JUnit Tests, convert them to Cactus tests and use the real
objects (not the Mocks).  This will give us our "in-container"
integration tests.  

Does this sound like an appropriate approach?  Should I be doing
something different?  Our environment will be using Web Services and
EJB.  Will I be able to perform my code-logic unit tests outside the
scope of a container, or will these need to be run in the same fashion
as Cactus tests (ie. in container)?

Figuring out some of these questions would be great in understanding how
we can best use Cactus.  Thanks for any help you can provide.

Dawson


Re: Mock objects with Cactus

Posted by Milan Trajkovic <mi...@gmail.com>.
Hello.
I have the similar doubts myself.
I think that converting tests from ones that use Mock objects to
cactus approach is far from trivial, and requires significant effort.
Is there some way to make it easier?


On Wed, 09 Mar 2005 10:00:50 -0400, Dawson Mossman
<da...@bulletproofsi.com> wrote:
> Hi Vincent,
> I am fairly new to Cactus and am trying to understand exactly how it
> should work.
> 
> Our organization wants to perform code logic unit testing and
> integration testing (we'll worry about functional testing later).  For
> our code logic unit testing, we are planning on doing JUnit tests with
> Mock objects.
> 
> This is the strategy I am thinking we could use:
> 1) As we develop individual classes we will write JUnit tests using Mock
> objects to test class methods.
> 2) Then, as we begin to integrate components (classes), we will take the
> existing JUnit Tests, convert them to Cactus tests and use the real
> objects (not the Mocks).  This will give us our "in-container"
> integration tests.
> 
> Does this sound like an appropriate approach?  Should I be doing
> something different?  Our environment will be using Web Services and
> EJB.  Will I be able to perform my code-logic unit tests outside the
> scope of a container, or will these need to be run in the same fashion
> as Cactus tests (ie. in container)?
> 
> Figuring out some of these questions would be great in understanding how
> we can best use Cactus.  Thanks for any help you can provide.
> 
> Dawson
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 
>

RE: Mock objects with Cactus

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Dawson,

> -----Original Message-----
> From: Dawson Mossman [mailto:dawson.mossman@bulletproofsi.com]
> Sent: mercredi 9 mars 2005 15:01
> To: Cactus Users List
> Subject: Mock objects with Cactus
> 
> Hi Vincent,
> I am fairly new to Cactus and am trying to understand exactly how it
> should work.
> 
> Our organization wants to perform code logic unit testing and
> integration testing (we'll worry about functional testing later).  For
> our code logic unit testing, we are planning on doing JUnit tests with
> Mock objects.
> 
> This is the strategy I am thinking we could use:
> 1) As we develop individual classes we will write JUnit tests using Mock
> objects to test class methods.
> 2) Then, as we begin to integrate components (classes), we will take the
> existing JUnit Tests, convert them to Cactus tests and use the real
> objects (not the Mocks).  This will give us our "in-container"
> integration tests.
> 
> Does this sound like an appropriate approach?  

I really think you should keep your code logic unit tests and not remove
them. Integration tests and tests in isolation are 2 different things and
both are needed.

Here's what I suggest:
- you do most of your tests using mock objects in isolation
- you add *some* integration tests just to prove that the integration work
- you add functional tests. If they can be automated then all the best and
you could possibly have the majority of your integration/functional tests as
proper functional tests. 

> Should I be doing
> something different?  Our environment will be using Web Services and
> EJB.  Will I be able to perform my code-logic unit tests outside the
> scope of a container, or will these need to be run in the same fashion
> as Cactus tests (ie. in container)?

The only trick for writing code logic unit test is realizing that the design
of your application is extremely important and it may or may not allow you
to write them easily. If you do TDD, then by definition you'll have a design
that support them. Otherwise you may need to do quite extensive refactoring.

> 
> Figuring out some of these questions would be great in understanding how
> we can best use Cactus.  Thanks for any help you can provide.

Yes, I agree. This is exactly why I've written JUnit in Action (which is the
sum of my 4-5 years of unit testing experience). It answers exactly the
questions you're asking :-)

Thanks
-Vincent

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran�ais !
Yahoo! Mail : http://fr.mail.yahoo.com