Hi

hacked quickly this morning a small junit rule to ease tomee maven plugin
tests.

Here is a sample:
http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java

Basically you just need to add the TomEEMavenPluginRule (which relies on
Start mojo but it is far enough to test common parts of the plugin which
are the ones where the logic is):


@Rule
public TomEEMavenPluginRule TMPRule = new TomEEMavenPluginRule();


Then you write the test you want to do as usual. A plugin instance is
executed by test method.

You can inject the http base url through @Url private String url;

And you can configure plugin attributes simply defining them as test class
attributes (initialized and decorated with @Config, the mojo attribute name
will match the test class attribute name):

@Config private String tomeeHost = "localhost"; // overrides mojo tomeeHost

I just pushed the previous test class (which is clearly not enough to
prevent regressions) but now we can test all we add to the plugin.

Note: I didn't use the maven harness artifact which have dependencies
issues ATM and is not as easy as it should IMO. If i missed something be
free to correct the rule i proposed directly.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*

Reply via email to