Sławomir,

I seem to be a bit lost.  I am able to generate the test poms in testing
directories.

I am able to generate POMs and associated test files during the
generate-test-sources phase.  My test code looks like:


/**
 * Generated test for config/withDefaults
 */
@Test
@InjectMojo(goal = "check")
@Basedir("target/test-classes/org/apache/rat/maven/stubs/config/withDefaults")
public void configWithDefaultsTest(RatCheckMojo mojo) throws
MojoExecutionException {
    TestData testData = testDataMap.get("config/withDefaults");

testData.setupFiles(Paths.get("target/test-classes/org/apache/rat/maven/stubs/config/withDefaults"));
    if (testData.getExpectedException() != null) {

assertThatThrownBy(mojo::execute).hasMessageContaining(testData.getExpectedException().getMessage());
    } else {
        mojo.execute();
        ValidatorData validatorData = new ValidatorData(mojo.getOutput(),
"src/test/resources/org/apache/rat/maven/config/noDefaults");
        testData.getValidator().accept(validatorData);
    }
}



The RatCheckMojo has a parameter :


/** The xml output file. */
@Parameter(defaultValue = "${project.build.directory}/.rat.xml", readonly =
true)
protected File xmlOutputFile;


When the mojo executes, the "xmlOutputFile" is set to
target/test-classes/org/apache/rat/maven/stubs/config/withDefaults/${project.build.directory}/.rat.xml
So my question is how can I get the ${project.*} properties populated
inside the test mojo under test?

I am trying to maintain a maven implementation that will support Maven 3.x

The pom in the
target/test-classes/org/apache/rat/maven/stubs/config/withDefaults directory
would not work unless I added a "<project implementatikon=.../>" element.
But this seems like it may be a bastardization halfway between the JUnit3
and JUnit5 implementations.

I am using
<mavenVersion>3.9.12</mavenVersion>
<mavenPluginTestingVersion>3.4.0</mavenPluginTestingVersion>
<mavenPluginToolsVersion>3.15.2</mavenPluginToolsVersion>

The code is in [1].  The tools submodule generates the test code as well as
a base abstract class for the mojos.

[1]
https://github.com/apache/creadur-rat/tree/feature/restructure/apache-rat-plugin-parent

Any assistance would be appreciated.

Claude

Reply via email to