Skip to content

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
@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?

@slachiewicz slachiewicz added this to the 4.0.0-beta-4 milestone Mar 19, 2025
@jira-importer
Copy link

Resolve #192

@Bukama
Copy link

Bukama commented Aug 3, 2025

@aamotharald Same here :)

@slawekjaranowski slawekjaranowski force-pushed the contribution/MPLUGINTESTING-93 branch from c58431e to 4f7af5a Compare October 12, 2025 16:08
@slawekjaranowski slawekjaranowski modified the milestones: 4.0.0-beta-5, 3.4.0 Oct 12, 2025
@slawekjaranowski
Copy link
Member

@gnodet @slachiewicz @aamotharald I have rebased and fix build

I hope we can process it forward

@slawekjaranowski slawekjaranowski marked this pull request as ready for review October 12, 2025 16:35
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;

/**
* TODO: add a way to use the plugin POM for the lookup so that the user doesn't have to provide the a:g:v:goal
Copy link
Contributor

Choose a reason for hiding this comment

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

That looks slightly weird to add a bunch of TODO and deprecate the class at the same time...

Copy link
Member

Choose a reason for hiding this comment

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

I will remove TODO from deprecated classes .... 😄

Copy link
Member

Choose a reason for hiding this comment

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

done

import static org.junit.jupiter.api.Assertions.assertEquals;

@MojoTest
class Junit5Test {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why removing this one ? Is it duplicating another test ?

Copy link
Member

Choose a reason for hiding this comment

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

we have JUnit5 tests in maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ParametersMojoTest.java

@slawekjaranowski slawekjaranowski force-pushed the contribution/MPLUGINTESTING-93 branch from cfe7813 to a33ed8d Compare October 14, 2025 16:21
@slawekjaranowski
Copy link
Member

@gnodet @slachiewicz look ok for me .... I would like to process it

I will change PR title as we improve JUnit 5 implementation, documentation will be fixed in next PR

@aamotharald thanks for work

Comment on lines +134 to +137
String basedir = AnnotationSupport.findAnnotation(context.getElement().get(), Basedir.class)
.map(Basedir::value)
.orElse(getBasedir());
field.set(null, basedir);
Copy link
Member

Choose a reason for hiding this comment

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

this will be fixed with:

we should not override a static field

@slawekjaranowski slawekjaranowski changed the title [WIP] [MPLUGINTESTING-93] - Prepare documentation / examples for JUnit 5 and Maven 3 Improve JUnit5 extension, make similar to Maven 4 implementation Oct 14, 2025
@slawekjaranowski slawekjaranowski self-assigned this Oct 14, 2025
@slawekjaranowski slawekjaranowski added the enhancement New feature or request label Oct 14, 2025
@slawekjaranowski slawekjaranowski merged commit f46bdbe into apache:maven-plugin-testing-3.x Oct 14, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants