This is an example I plan to get a lot of mileage out of. It contains
100 unit tests written for Dao's (all in memory right now), Components
that perform simple validation and Business Objects that do NOT follow
the transfer object (anti) pattern. (When I got to around 95 tests
naturally, I went around looking for 5 more to add).
You can just download the file and have a look at the "test" directory
under the CarRental project. Alternatively, you can follow all of the
instructions and get them to run.
This example has several things embedded in it, including:
- A simple use of Spring
- An aspect that outputs the time each unit test takes to run
(mentioned earlier on this list)
- Yet another simple wrapper around Log4J that actually adds value by
using variable arguments
- Several examples of the use of Generics (both types and methods)
- What something looks like after using both PMD and Checkstyle
- JUnit, of course
I plan to extend this example over the next several months (as time
permits). On my TO DO list (not necessarily in priority order):
- Introduce Hibernate (replace all of the in-memory Dao's with
hibernate)
- Rewrite (by hand) every test using TestNG (for experience - I don't
want to just convert them so I can learn TestNG from the ground up -
and I figure after writing that many tests I'll have enough experience
to intelligently speak about both JUnit and TestNG)
- I'll add some kind of front end, have not yet decided.
- Plan out more possible Aspect assignments to be applied to this
example (that's the original impetus for this work - part 2 of a 3-part
class on AOP and AspectJ)
Comments welcome.
Oh, if you do follow all of the instructions and you install everything
under the same directory, it will take up roughly 312 MB (+ some for
the block size used by your hard drive).
FYI, the last time I checked, the ratio of the "source" code to the
"test" code was 3:2. That is, around 1500 non-comment source statements
for the src directory and about 1000 non-comment source statements for
the test directory. Are your results similar?
Brett
Tutorials and Articles
http://schuchert.wikispaces.com/
I'd appreciate any feedback you might want to offer:
http://schuchert.wikispaces.com/Car+Rental+Code+Coverage+with+Emma
Thanks!
Brett
Tutorials and Articles
http://schuchert.wikispaces.com/
Brett L. Schuchert wrote:
> http://schuchert.wikispaces.com/Car+Rental+Example
>