myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Korhonen, Kalle" <>
Subject RE: SVN Reorg
Date Tue, 21 Jun 2005 17:21:15 GMT
First, thanks Sean for doing the heavy lifting. Restructuring the whole
codebase is always more cumbersome than it should and you always end up
breaking some little pieces. But, it's needed and it's always better to
do it as soon as possible. Ignore people who'll ask "why do we need this
again?" :)

> -----Original Message-----
> From: Sean Schofield [] 
> Subject: SVN Reorg
> There are a few things that will have to be sorted out after 
> the initial phase.  One example is unit tests which are kind 
> of scattered.

One thing I've been promoting here is to implement unit tests as inner
classes. In case of restructuring and renaming, you wouldn't need to
worry about moving your unit tests; but they would always go with the
main classes. This somewhat controversial idea has several benefits:
- Your unit test class is always kept with the main class if you decide
to refactor it into a different package.
- You can name all your test classes the same way, for example as
UnitTests (so you get a bunch of classes called $UnitTests), which can
then easily be identified be removed from deployment builds.
- Inner classes can access all of the fields and methods of the parent
class, including private ones, so you don't need to compromise your code
encapsulation and information hiding design to instantiate and populate
the class you are testing.
- Since inner classes have the same scope as their parents, there's no
need to rewrite import clauses.

Some say that then you'd be mixing your test code with business code,
but it's quite the opposite; when compiled, they are compiled as
separate classes and since inner classes can access all private members
of the parent class, you don't need to change your business code to make
it suitable for unit testing. It's a trivial exercise to delete all
*$UnitTests.class files from the output folder when you are ready to
deploy your classes.

For MyFaces unit testing, just throwing out the idea for others to think


View raw message