dev@glassfish.java.net

supporting standalone tests in V3

From: Lloyd L Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Tue, 15 Apr 2008 12:46:51 -0700

I am currently trying to figure out how to port V2 AMX tests to V3.

In V3, how can we support tests other than plain vanilla unit tests?
- might or might not be true unit tests
- might or might not be junit tests
- might need special setup to execute.

What I would like is formal support for compiling (and optionally
executing) test code that lives other than under the test/ directory.

More details--

In V3 we have a structure that supports unit tests--source code goes
under src/main/java and test code goes under src/test/java. The build
compiles both automagically--very nice!

In V2 I developed a fairly large set of tests for the AMX management
API. While the tests are not unit tests in the usual sense, they
junit.framework.TestCase tests, and run (in V2) using the junit test
framework. The tests do *end-to-end* testing from a client to a
running server, and given the inherent nature of what needs to be
tested, this is the best approach for this particular case; mock
objects offer little value since the goal is to test the end-to-end
behavior, not some isolated piece of code.

So let me call these "End to End Tests" or EETs. These don't work
when placed in the test/ directory, since they require a test
environment with a full running server--they'll all just fail. So I
can't put my test code under tests/. Annotating them with @Ignore is
no good either, because they *must* be run when the right setup is in
place.

Unfortunately, if the test code does not live under test/, then it has
to live elsewhere, along with some kind of build script. That means
making that script rely on build products of the regular build, eg
duplicating and maintaining knowledge found elsewhere in the build.

---
Lloyd L Chambers
lloyd.chambers_at_sun.com
Sun Microsystems, Inc