Package org.nuiton.plugin
Class MojoTestRule<P extends org.nuiton.plugin.AbstractPlugin>
java.lang.Object
org.apache.maven.plugin.testing.MojoRule
org.nuiton.plugin.MojoTestRule<P>
- All Implemented Interfaces:
org.junit.rules.TestRule
public class MojoTestRule<P extends org.nuiton.plugin.AbstractPlugin>
extends org.apache.maven.plugin.testing.MojoRule
TODO Review this documentation.
To offer inside each test method (annotated by a
Test) the following properties :
testDirectory: location where to find resources for the testpomFile: location of the pom file to use to build the mojomojo: the instanciated and initialized mojo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) protected voidbefore()protected PcreateMojo(File pomFile, String goalName) getMojo()protected FilegetPomFile(File testDir, String methodName) Obtain the location of the pom file to use for next mojo test.protected FilegetTestDir(String methodName) Obtain the location of the directory where to find resources for the next test.booleanstatic <P extends org.nuiton.plugin.AbstractPlugin>
MojoTestRule<P>protected voidInitialize the given mojo.protected voidtearDownMojo(P mojo) Methods inherited from class org.apache.maven.plugin.testing.MojoRule
configureMojo, configureMojo, executeMojo, executeMojo, executeMojo, executeMojo, extractPluginConfiguration, extractPluginConfiguration, getContainer, getPluginDescriptorLocation, getPluginDescriptorPath, getPublicDescriptorStream, getVariablesAndValuesFromObject, getVariablesAndValuesFromObject, getVariableValueFromObject, lookup, lookupConfiguredMojo, lookupConfiguredMojo, lookupConfiguredMojo, lookupEmptyMojo, lookupEmptyMojo, lookupMojo, lookupMojo, lookupMojo, newMavenSession, newMojoExecution, readMavenProject, setupContainer, setupContainerConfiguration, setVariableValueToObject
-
Constructor Details
-
MojoTestRule
-
-
Method Details
-
newRule
public static <P extends org.nuiton.plugin.AbstractPlugin> MojoTestRule<P> newRule(Class<?> testClass, String goalName) -
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
applyin interfaceorg.junit.rules.TestRule- Overrides:
applyin classorg.apache.maven.plugin.testing.MojoRule
-
createMojo
- Throws:
Exception
-
setUpMojo
Initialize the given mojo.- Parameters:
mojo- the instanciate mojopomFile- the pom file used to instanciate the mojo- Throws:
Exception- if any pb
-
initMojo
-
tearDownMojo
-
before
- Overrides:
beforein classorg.apache.maven.plugin.testing.MojoRule- Throws:
Throwable
-
after
protected void after()- Overrides:
afterin classorg.apache.maven.plugin.testing.MojoRule
-
getMojo
-
getPomFile
-
getTestDirectory
-
getTestDir
Obtain the location of the directory where to find resources for the next test. By convention, will be the package named by the test class name from theTestHelper.getTestBasedir().- Parameters:
methodName- the method of the next test to execute- Returns:
- the directory where to find resources for the test
-
getPomFile
Obtain the location of the pom file to use for next mojo test. By default, the pom file is the file with namemethodName+".xml"in thetestDir.- Parameters:
testDir- the location of resources for the next test (is the result of the methodgetTestDir(String).methodName- the name of the next test- Returns:
- the location of the pom file for the next mojo test.
-
getRelativePathFromBasedir
-