Hi,

I wanted to let people know about something I've been working on for the
assembly plugin. As anyone watching the commit notifications has probably
noticed, I've recently completed a large refactor of the assembly plugin,
with the aim of making it more modular and easier to unit test. While this
has made the source easier to comprehend and unit test, I've learned an
important lesson in the process: test coverage numbers don't tell the whole
story. Some of you have tried to tell me this in the past, but let's just
say there's nothing like experiencing something firsthand...

So, to make up for deficiencies in the unit tests (not checking every
permutation of nulls, for example), I wanted to put together some functional
tests which would help us set a high water mark for future releases, to
prevent regressions (or try to). The trouble has been that this really
requires running the plugin within its platform - i.e. Maven itself - and
checking the results of various builds. Further complicating things is the
fact that plugins are sometimes resolved early in the build lifecycle,
meaning the instance that actually gets tested will be something resolved
from the local repository instead of the one you just built.

This brings me to my announcement: I've written two new plugins, which are
currently in the sandbox, and which allow developers to run integration-test
builds for a plugin. The way it works is relatively simple:

1. backup the local repository plugin directory structure, and stage out the
fresh one
2. clear the resolved-plugin cache of the plugin you just built
3. run a series of Maven builds, executing pre-build and verification
scripts before/after each build to setup and verify the test, respectively
4. de-stage the plugin, meaning restore the local repository state prior to
the integration test setup

For items 1, 2, and 4, I've written the maven-plugin-test-plugin (I know,
ugly name). Item 3 is another plugin I wrote, called the
maven-invoker-plugin, which can be used to run any [set of] builds. It uses
beanshell scripts for prebuild and verification, can take CLI-injected
properties from a test.properties file in the build directory, and supports
a goals.txt file for customizing the build command used per-project.

As I mentioned, both of these plugins are in the sandbox. I've also deployed
them to the apache.snapshots repository, and you can find a sample
configuration in a profile in the maven-assembly-plugin POM.

Hopefully, we can use and evolve this pattern to start enabling
functional/integration tests for plugins which are easy to understand and
maintain.

Cheers,

John

Reply via email to