You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Matt Watson (JIRA)" <ji...@apache.org> on 2015/05/19 22:43:00 UTC

[jira] [Comment Edited] (MPLUGINTESTING-34) Documentation: sample code using MojoRule doesn't work

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

Matt Watson edited comment on MPLUGINTESTING-34 at 5/19/15 8:42 PM:
--------------------------------------------------------------------

I've had a similar experience to Cristiano. The jUnit 4 example that uses a MojoRule does not compile at the line:

{code}
        File pom = rule.getTestFile( "src/test/resources/unit/project-to-test/pom.xml" );
{code}

I got it working by using a TestResource:

{code}
...
@Rule
public TestResources resources = new TestResources();
...

@Test
public void testSomething()
        throws Exception
    {
    	 File projectCopy = this.resources.getBasedir( pathToTestProjectBaseDirectory );
         File pom = new File( projectCopy, "pom.xml" );
         ....
    }

{code}


was (Author: mattwatson):
I've had a similar experience to Cristiano. ThejUnit 4 example that uses a MojoRule does not compile at the line:

{code}
        File pom = rule.getTestFile( "src/test/resources/unit/project-to-test/pom.xml" );
{code}

I got it working by using a TestResource:

{code}
...
@Rule
public TestResources resources = new TestResources();
...

@Test
public void testSomething()
        throws Exception
    {
    	 File projectCopy = this.resources.getBasedir( pathToTestProjectBaseDirectory );
         File pom = new File( projectCopy, "pom.xml" );
         ....
    }

{code}

> Documentation: sample code using MojoRule doesn't work
> ------------------------------------------------------
>
>                 Key: MPLUGINTESTING-34
>                 URL: https://issues.apache.org/jira/browse/MPLUGINTESTING-34
>             Project: Maven Plugin Testing
>          Issue Type: Bug
>          Components: plugin-testing-harness
>    Affects Versions: 3.0.0
>            Reporter: Laird Nelson
>            Assignee: Jason van Zyl
>
> The cookbook reachable from https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/getting-started/index.html includes code like this:
> {code:java}
> File pom = rule.getTestFile( "src/test/resources/unit/project-to-test/pom.xml" );
> {code}
> This method does not exist on {{MojoRule}} (http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/apidocs/org/apache/maven/plugin/testing/MojoRule.html).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)