maven-plugin-testing-harness

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

maven-plugin-testing-harness

ahardy42
Is there life is in this testing harness still?

I'm looking at https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/ 

The link to JIRA returns  503 - http://jira.codehaus.org/browse/MPLUGINTESTING

and the link to git repo is 404

I can imagine there is a big population of maven users out there who look at it and give up, which is a shame because you can't beat a good test harness.

I have managed to put some code together to make my tests run nicely in IntelliJ and I was wondering if you wanted any documentation or example code?

I've still got issues and I've got a live question on StackOverflow: https://stackoverflow.com/questions/45241317/hard-time-mojo-testing-with-maven-plugin-testing-harness

Regards
Adam
Reply | Threaded
Open this post in threaded view
|

Re: maven-plugin-testing-harness

Karl Heinz Marbaise-3
Hi,

On 26/07/17 11:49, ahardy42 wrote:
> Is there life is in this testing harness still?
>
> I'm looking at
> https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/

>
> The link to JIRA returns  503 -
> http://jira.codehaus.org/browse/MPLUGINTESTING

Outch that are the old links which means there hasn't been a release for
a longer time ;-(

This is the new location:

https://issues.apache.org/jira/projects/MPLUGINTESTING/


>
> and the link to git repo is 404

https://github.com/apache/maven-plugin-testing

but it's out of date correct...

I have created an appropriate INFRA ticket to fix this[1].


[1]: https://issues.apache.org/jira/browse/INFRA-14716

>
> I can imagine there is a big population of maven users out there who look at
> it and give up, which is a shame because you can't beat a good test harness.

Yes this is unfortunately true...



>
> I have managed to put some code together to make my tests run nicely in
> IntelliJ and I was wondering if you wanted any documentation or example
> code?

Both is appreciated...sure ..


>
> I've still got issues and I've got a live question on StackOverflow:
> https://stackoverflow.com/questions/45241317/hard-time-mojo-testing-with-maven-plugin-testing-harness
>
> Regards
> Adam
>


Kind regards
Karl Heinz Marbaise

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: maven-plugin-testing-harness

Karl Heinz Marbaise-3
Hi,

On 26/07/17 20:13, Karl Heinz Marbaise wrote:

> Hi,
>
> On 26/07/17 11:49, ahardy42 wrote:
>> Is there life is in this testing harness still?
>>
>> I'm looking at
>> https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/
>
>>
>> The link to JIRA returns  503 -
>> http://jira.codehaus.org/browse/MPLUGINTESTING
>
> Outch that are the old links which means there hasn't been a release for
> a longer time ;-(
>
> This is the new location:
>
> https://issues.apache.org/jira/projects/MPLUGINTESTING/
>
>
>>
>> and the link to git repo is 404
>
> https://github.com/apache/maven-plugin-testing
>
> but it's out of date correct...
>
> I have created an appropriate INFRA ticket to fix this[1].
>
>
> [1]: https://issues.apache.org/jira/browse/INFRA-14716
>

Thanks to INFRA..already fixed the problem.

Kind regards
Karl Heinz Marbaise

>>
>> I can imagine there is a big population of maven users out there who
>> look at
>> it and give up, which is a shame because you can't beat a good test
>> harness.
>
> Yes this is unfortunately true...
>
>
>
>>
>> I have managed to put some code together to make my tests run nicely in
>> IntelliJ and I was wondering if you wanted any documentation or example
>> code?
>
> Both is appreciated...sure ..
>
>
>>
>> I've still got issues and I've got a live question on StackOverflow:
>> https://stackoverflow.com/questions/45241317/hard-time-mojo-testing-with-maven-plugin-testing-harness 
>>
>>
>> Regards
>> Adam
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: maven-plugin-testing-harness

ahardy42
In reply to this post by Karl Heinz Marbaise-3
On 26/07/17 11:49, ahardy42 wrote:
> Is there life is in this testing harness still?
>
> I'm looking at
> https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/

Hi All,
while I've made a lot of progress with my plugin testing with the maven-plugin-testing-harness, I'm stumped now because the setup and startup I've put in place isn't causing maven to set up the test project's classpath properly, so my resources from the test project (in the actual project's src/test/resources/my-test-project/src/main/resources dir) are missing.

Does that sound fixable?

Here's what I'm doing in my test:

        MojoRule mojoRule = new MojoRule(this);
        ClassLoader classLoader = getClass().getClassLoader();
        URL url = classLoader.getResource(TEST_POM);
        if (url == null) {
            throw new MojoExecutionException(String.format(
                    "Cannot locate %s", TEST_POM));
        }
        File pom = new File(url.getFile());
        MavenSettingsBuilder mavenSettingsBuilder = (MavenSettingsBuilder)
                getContainer().lookup(MavenSettingsBuilder.ROLE);
        Settings settings = mavenSettingsBuilder.buildSettings();
        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
        request.setPom(pom);
        request.setLocalRepositoryPath(settings.getLocalRepository());
        MavenExecutionRequestPopulator populator =
                getContainer().lookup(MavenExecutionRequestPopulator.class);
        populator.populateDefaults(request);
        DefaultMaven maven = (DefaultMaven) getContainer().lookup(Maven.class);
        DefaultRepositorySystemSession repoSession =
                (DefaultRepositorySystemSession)
                    maven.newRepositorySession(request);
        LocalRepository localRepository = new LocalRepository(
                request.getLocalRepository().getBasedir());
        SimpleLocalRepositoryManagerFactory factory =
                new SimpleLocalRepositoryManagerFactory();
        LocalRepositoryManager localRepositoryManager =
                factory.newInstance(repoSession, localRepository);
        repoSession.setLocalRepositoryManager(localRepositoryManager);
        ProjectBuildingRequest buildingRequest =
                request.getProjectBuildingRequest()
                        .setRepositorySession(repoSession)
                        .setResolveDependencies(true);
        ProjectBuilder projectBuilder = mojoRule.lookup(ProjectBuilder.class);
        MavenProject project =
                projectBuilder.build(pom, buildingRequest).getProject();
        MavenSession session = mojoRule.newMavenSession(project);
        session.setCurrentProject(project);
        session.setProjects(Collections.singletonList(project));
        request.setSystemProperties(System.getProperties());
        testMojo = (GenerateConfig) lookupConfiguredMojo(session,
                mojoRule.newMojoExecution("configure"));


Reply | Threaded
Open this post in threaded view
|

Re: maven-plugin-testing-harness

ahardy42
In reply to this post by Karl Heinz Marbaise-3
On 26/07/17 20:13, Karl Heinz Marbaise wrote:
>> and the link to git repo is 404
>
> https://github.com/apache/maven-plugin-testing
>
> but it's out of date correct...
>
> I have created an appropriate INFRA ticket to fix this[1].
>
>
> [1]: https://issues.apache.org/jira/browse/INFRA-14716


As far as I can tell, the fix didn't work. I updated the JIRA issue but I was unable to re-open the ticket and I could only leave "internal comments" which aren't publicly visible, despite  logging in.

What would also be incredibly useful is a link to the wiki for maven-plugin-testing-harness

I assume there is one, I just can't find any link to one anywhere.

regards
Adam
Reply | Threaded
Open this post in threaded view
|

Re: maven-plugin-testing-harness

ahardy42
In reply to this post by ahardy42
After a concentrated stint of experimentation, I have setup my tests using the maven-plugin-testing-harness so that the tests run with a live remote repository and have all the resources provided in the target/test-classes directory.

The solution is here: https://stackoverflow.com/questions/45241317/hard-time-mojo-testing-with-maven-plugin-testing-harness/45833419#answer-45833419

Sorry if the question title betrays my frustration. The limited feedback I got here on this user list was also surprising. Obviously with no feedback to speak of, I have no idea why no-one from the maven community wanted to communicate on this subject. I would of course be grateful now to get some feedback of any kind. I'm not asking for anyone to spend more than a minute to write a reply - I have essentially finished my work with the testing harness.

Why was it so difficult? Are the inner workings all in the process of re-development for maven 4?
Reply | Threaded
Open this post in threaded view
|

Re: maven-plugin-testing-harness

olamy
Hi
IMHO using the maven invoker plugin is a better way as you can easily test
your plugin with different core versions.
but it's only my POV :-)

On 23 August 2017 at 18:03, ahardy42 <[hidden email]> wrote:

> After a concentrated stint of experimentation, I have setup my tests using
> the maven-plugin-testing-harness so that the tests run with a live remote
> repository and have all the resources provided in the target/test-classes
> directory.
>
> The solution is here:
> https://stackoverflow.com/questions/45241317/hard-time-
> mojo-testing-with-maven-plugin-testing-harness/45833419#answer-45833419
>
> Sorry if the question title betrays my frustration. The limited feedback I
> got here on this user list was also surprising. Obviously with no feedback
> to speak of, I have no idea why no-one from the maven community wanted to
> communicate on this subject. I would of course be grateful now to get some
> feedback of any kind. I'm not asking for anyone to spend more than a minute
> to write a reply - I have essentially finished my work with the testing
> harness.
>
> Why was it so difficult? Are the inner workings all in the process of
> re-development for maven 4?
>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.
> com/maven-plugin-testing-harness-tp5911556p5912964.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Olivier Lamy
http://twitter.com/olamy | http://linkedin.com/in/olamy
Reply | Threaded
Open this post in threaded view
|

Re: maven-plugin-testing-harness

ahardy42
maven-invoker-plugin looks very useful, but it just adds to the frustration that the maven website guided me down this path with maven-plugin-testing-harness without a single mention of maven-invoker-plugin.

you might want to put a link in there in the "my first mojo resources" section.

I'll try it out when we upgrade maven and my tests break.