[ 
https://issues.apache.org/jira/browse/MCOMPILER-588?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17836854#comment-17836854
 ] 

Mikhail Deviatov edited comment on MCOMPILER-588 at 4/13/24 8:11 PM:
---------------------------------------------------------------------

I faced with a problem trying to apply native solution.
{code:java}
@MojoTest
public class CompilerTest {

    @Test
    @InjectMojo(goal = "compile", pom = 
"classpath:/target/test-classes/unit/compiler-basic-test/plugin-config.xml")
    void testCompilerBasic(CompilerMojo compileMojo) throws Exception {         
 Log log = mock(Log.class);

        compileMojo.setLog(log);

        compileMojo.execute();

        File testClass = new File(compileMojo.getOutputDirectory(), 
"foo/TestCompile0.class");

        assertTrue(testClass.exists());
    }
}
{code}
produce an error
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.015 s 
<<< FAILURE! – in org.apache.maven.plugin.compiler.CompilerTest
[ERROR] org.apache.maven.plugin.compiler.CompilerTest – Time elapsed: 0.015 s 
<<< ERROR!
java.lang.NoClassDefFoundError: org/apache/maven/api/xml/XmlNode

package with this class was intoduce in 4.0.0-alpha-2 version of maven
[https://mvnrepository.com/artifact/org.apache.maven/maven-api-xml|http://example.com/]

 

internal Maven API is still subject to change
switch to JUnit5 support was introduce in Maven version 3.5.4
later minimum version of Maven was increased to 3.6.3
now it requires 4.0.0-alpha-2 just to start a simple test.

do we really need to wait when API is stabilized?
my solution binds to internal API specific version of 
*maven-plugin-testing-harness* that is not gonna be subject to change. Applying 
it we get JUnit5 support right away. when internal maven API can be applied we 
can drop my solution in favor of native support.
what do you think about this approach?

 


was (Author: JIRAUSER305049):
I faced with a problem trying to apply native solution.
{code:java}
@MojoTest
public class CompilerTest {

    @Test
    @InjectMojo(goal = "compile", pom = 
"classpath:/target/test-classes/unit/compiler-basic-test/plugin-config.xml")
    void testCompilerBasic(CompilerMojo compileMojo) throws Exception {         
 Log log = mock(Log.class);

        compileMojo.setLog(log);

        compileMojo.execute();

        File testClass = new File(compileMojo.getOutputDirectory(), 
"foo/TestCompile0.class");

        assertTrue(testClass.exists());
    }
}
{code}
produce an error
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.015 s 
<<< FAILURE! – in org.apache.maven.plugin.compiler.CompilerTest
[ERROR] org.apache.maven.plugin.compiler.CompilerTest – Time elapsed: 0.015 s 
<<< ERROR!
java.lang.NoClassDefFoundError: org/apache/maven/api/xml/XmlNode

package with this class was intoduce in 4.0.0-alpha-2 version of maven
[https://mvnrepository.com/artifact/org.apache.maven/maven-api-xml|http://example.com/]

 

internal Maven API is still subject to change
switch to JUnit5 support was introduce in Maven version 3.5.4
later minimum version of Maven was increased to 3.6.3
now it requires 4.0.0-alpha-2 just to start a simple test.

do we really need to wait when API is stabilized?
my solution binds to internal API *maven-plugin-testing-harness* that is not 
gonna be subject to change for a very long time. Applying it we get JUnit5 
support right away. when internal maven API can be applied we can drop my 
solution in favor of native support.
what do you think about this approach?

 

> JUnit4 test framework to JUnit5 migration
> -----------------------------------------
>
>                 Key: MCOMPILER-588
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-588
>             Project: Maven Compiler Plugin
>          Issue Type: Improvement
>            Reporter: Mikhail Deviatov
>            Priority: Major
>
> We have JUnit5 test framework for a long time. 
> It have modular architecture, good support in IDE and quite fast. It would be 
> good to add support JUnit5 to the project.
> The problem is that there are 2 library used for testing in project 
> *maven-plugin-testing-harness* and *org.eclipse.sisu.plexus* and they both 
> don't have JUnit5 support.
> I created a solution that overrides parts of code used derived and my own 
> implementation.
> Please take a look at it
> https://github.com/apache/maven-compiler-plugin/pull/233



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to