On Mon, 24 Nov 2025 at 20:19, Claude Warren <[email protected]> wrote:

> Greetings,
>
> I am working on the Apache RAT Maven plugin.  We are attempting to migrate
> to Maven 3.4.0.
>
> I have a comment and then a question.
>
> Comment:
>
> https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/getting-started/index.html
> states that the AbstractMojoTestCase is deprecated and that the "MojoTest"
> annotation should be used, but the example code at the bottom of the page
> still shows an AbstractMojoTestCase example.  I feel that this example
> should be replaced with how to make the MojoTest case work or at least more
> strongly point to the MojoTest case recipe.
>

You are right, the documentation is to fix, update.
More examples you can found in code tests:
https://github.com/apache/maven-plugin-testing/blob/maven-plugin-testing-3.x/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ParametersMojoTest.java


> Question:
>
> The @MojoTest annotation allows use of the @InjectMojo annotation.  which
> will accept a POM as an argument to the annotation.  My problem with this,
> and my biggest issue with annotations, is that I need to specify the POM at
> runtime, not at compile time.
>
> In the RAT ecosystem, everything is first defined in the CLI.  The Maven
> implementation converts the CLI options into Maven options.  So when we add
> new CLI options the Maven implementation automatically picks them up.  We
> have the ability to generate the POMs to test the various options.  What I
> don't have is a way to specify the POM and get a constructed Mojo within a
> JUnit test environment.  I have not looked but I suspect the same is true
> for an integration test as well.
>
> So the question is: Is there a simple way to generate the Mojo from a POM
> within the setup of a JUnit 5 test?
>
> Any pointers would be appreciated, and thank you for all your hard work in
> building the Maven tooling environment.
>

You can try generate a pom in @BeforeEach method
When you set Basedir for a test it will be available in setup method

Please look at example in test BaseDirInBeforeEach



>
> Claude
>


-- 
Sławomir Jaranowski

Reply via email to