Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [MPLUGINTESTING-93] - Prepare documentation / examples for JUnit 5 and Maven 3 #50

Draft
wants to merge 6 commits into
base: maven-plugin-testing-3.x
Choose a base branch
from

Conversation

aamotharald
Copy link
Contributor

@aamotharald aamotharald commented Dec 13, 2024

starting some documentation activities now and performing testing of the JUnit5 maven-plugin testing capabilities with existing open source maven plugins.

@gnodet I have made a small change in the MojoExtension as I think it's valid to have no configuration for your maven plugin at all. I'll just take the commit away if my understanding here is wrong

@aamotharald aamotharald marked this pull request as draft December 13, 2024 10:12
@aamotharald aamotharald changed the title [WIP] MPLUGINTESTING-93 [WIP] [MPLUGINTESTING-93] - Prepare documentation / examples for JUnit 5 and Maven 3/4 Dec 13, 2024
@aamotharald aamotharald changed the title [WIP] [MPLUGINTESTING-93] - Prepare documentation / examples for JUnit 5 and Maven 3/4 [WIP] [MPLUGINTESTING-93] - Prepare documentation / examples for JUnit 5 and Maven 3 Dec 13, 2024
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.plugin.testing.junit5;
package org.apache.maven.api.plugin.testing;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may collide with Maven 4 apis

Copy link
Contributor Author

@aamotharald aamotharald Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @slachiewicz ,
yes this might collide and this I am doing by intent.
Consider the following use case:
Somebody uses @InjectMojoon maven version 3 and creates JUnit Jupiter test cases to test his/her Mojo.

Then he/she decides to migrate to Maven4.
As the codelines differ between maven3/maven4, there might be glitches / issues. But the migration will be a lot less cumbersome if you don't have to rename all the imports just because the package changes from maven3 to maven4. This is why I would like to have the same Packages on Maven3/4.
Does that make sense or should we strictly separate the packages and make the maven3-4 migration cumbersome for the consumers?

PS: I made some experiments and at least for my limited use cases the migration from maven3 to 4 with this setup went really smooth. Still thinking how to deal with One Exception which got relocated between 3 to 4 which I plan to provide some further solution.

@gnodet
Copy link
Contributor

gnodet commented Jan 7, 2025

This is really interesting.
I'd like to see some changes from c6ef221 back ported to make the annotations identical (the @Inherited and the changes in InjectMojo).
Maybe also the new @Basedir annotation ?

@aamotharald
Copy link
Contributor Author

aamotharald commented Jan 9, 2025

Hi @gnodet ,
I have been able to to make the Annotations identical (added @Inherited and removed the boolean flag from InjectMojo).
I was also able to backport the @Basedir Annotation and added a unit test for that behaviour.

So what's left open is the stubbing. I made a check and backporting all the stubs seems to be a bigger task. My current opinion is to NOT offer the stubs on maven 3 (which means maven-plugin-testing with stubs is only possible with old JUnit 4 style tests extending the AbstractMojoTestCase). What is your opinion there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants