You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ed Hillmann <ed...@gmail.com> on 2011/11/17 05:52:54 UTC

Surefire not behaving the way I expect....

Hi.  I have a test which takes a long time to run.  What I'd like to do is
exclude this test (written in JUnit) from the normal test phase, and only
run it when a specific profile is defined.  So, in my pom, I configure the
surefire plugin with an excludes element, which contains the exclude child
element containing the name of the Test to skip.  And, it works great.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>

<CUSTOM_HOME>${project.basedir}/src/main/config</CUSTOM_HOME>
                    </systemPropertyVariables>

<argLine>-Djava.library.path=${jniLpSolverLibPath}</argLine>
                    <excludes>
                        <exclude>**/UseCaseUnitTest.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

Now, I've added a profile to the POM file, which is the same as the default
setting, but instead the excluded tag is empty.  However, the test is
always excluded.  No matter how I configure the profile, it always skips
over the test because it always picks up the original excludes definition.
I've tried defining this in or out of an execution in the profile.

        <profile>
            <id>tests.allTests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes/>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

This goes against, well, every page and blog entry which tells you this
should happen.  I'm using version 2.10 of the surefire plugin on mvn
3.0.3.  Am I doing something wrong?  Or has this stopped working?  My guess
is I'm doing something not quite right, but I don't know what to do to
correct this.

Thanks for any help,
Ed

Re: Surefire not behaving the way I expect....

Posted by Ed Hillmann <ed...@gmail.com>.
That did the trick.  All I did in my profile was update the configuration
element from this

                        <configuration>
                            <excludes/>
                        </configuration>

to this

                        <configuration>
                            <excludes combine.self="override"/>
                        </configuration>

And it's doing exactly what I want.  Having struggled with this before,
this new feature of 3.0.2 is very handy.  Whoever came up with it, thanks!

Thanks for the help,
Ed

On Thu, Nov 17, 2011 at 5:03 PM, Anders Hammar <an...@hammar.net> wrote:

> Try the merge process config explained here:
>
> http://www.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/
>
> /Anders
>
> On Thu, Nov 17, 2011 at 05:52, Ed Hillmann <ed...@gmail.com> wrote:
> > Hi.  I have a test which takes a long time to run.  What I'd like to do
> is
> > exclude this test (written in JUnit) from the normal test phase, and only
> > run it when a specific profile is defined.  So, in my pom, I configure
> the
> > surefire plugin with an excludes element, which contains the exclude
> child
> > element containing the name of the Test to skip.  And, it works great.
> >
> >            <plugin>
> >                <groupId>org.apache.maven.plugins</groupId>
> >                <artifactId>maven-surefire-plugin</artifactId>
> >                <configuration>
> >                    <systemPropertyVariables>
> >
> > <CUSTOM_HOME>${project.basedir}/src/main/config</CUSTOM_HOME>
> >                    </systemPropertyVariables>
> >
> > <argLine>-Djava.library.path=${jniLpSolverLibPath}</argLine>
> >                    <excludes>
> >                        <exclude>**/UseCaseUnitTest.java</exclude>
> >                    </excludes>
> >                </configuration>
> >            </plugin>
> >        </plugins>
> >    </build>
> >
> > Now, I've added a profile to the POM file, which is the same as the
> default
> > setting, but instead the excluded tag is empty.  However, the test is
> > always excluded.  No matter how I configure the profile, it always skips
> > over the test because it always picks up the original excludes
> definition.
> > I've tried defining this in or out of an execution in the profile.
> >
> >        <profile>
> >            <id>tests.allTests</id>
> >            <build>
> >                <plugins>
> >                    <plugin>
> >                        <groupId>org.apache.maven.plugins</groupId>
> >                        <artifactId>maven-surefire-plugin</artifactId>
> >                        <configuration>
> >                            <excludes/>
> >                        </configuration>
> >                    </plugin>
> >                </plugins>
> >            </build>
> >        </profile>
> >
> > This goes against, well, every page and blog entry which tells you this
> > should happen.  I'm using version 2.10 of the surefire plugin on mvn
> > 3.0.3.  Am I doing something wrong?  Or has this stopped working?  My
> guess
> > is I'm doing something not quite right, but I don't know what to do to
> > correct this.
> >
> > Thanks for any help,
> > Ed
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Surefire not behaving the way I expect....

Posted by Ed Hillmann <ed...@gmail.com>.
Thanks for that.  That sounds a lot like TestNG's groups, which is a good
thing.  :)

Thanks again.  I'll check this out.
Ed

On Fri, Nov 18, 2011 at 5:19 PM, Kristian Rosenvold <
kristian.rosenvold@zenior.no> wrote:

> FWIW, surefire 2.11-SNAPSHOT supports the use of JUnit @Categories, which
> I believe a lot of users should be looking at for
> including/excluding tests, since it allows you to tag at the class/method
> level and apply multiple include/exclude filters, which means you can
> cross-cut a much more specific selection on your test-base.
>
> As long as you use junit 4.8 and the surefire 4.7 provider, you can use
> the groups the excludedGroups parameter.
>
> Kristian
>
>
>
> Den 17.11.2011 14:46, skrev Benson Margulies:
>
>> Note that I ported this into the formal documentation of the POM as well.
>>
>> On Thu, Nov 17, 2011 at 2:03 AM, Anders Hammar<an...@hammar.net>  wrote:
>>
>>> Try the merge process config explained here:
>>> http://www.sonatype.com/**people/2011/01/maven-how-to-**
>>> merging-plugin-configuration-**in-complex-projects/<http://www.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/>
>>>
>>> /Anders
>>>
>>> On Thu, Nov 17, 2011 at 05:52, Ed Hillmann<ed.hillmann@gmail.com**>
>>>  wrote:
>>>
>>>> Hi.  I have a test which takes a long time to run.  What I'd like to do
>>>> is
>>>> exclude this test (written in JUnit) from the normal test phase, and
>>>> only
>>>> run it when a specific profile is defined.  So, in my pom, I configure
>>>> the
>>>> surefire plugin with an excludes element, which contains the exclude
>>>> child
>>>> element containing the name of the Test to skip.  And, it works great.
>>>>
>>>>            <plugin>
>>>>                <groupId>org.apache.maven.**plugins</groupId>
>>>>                <artifactId>maven-surefire-**plugin</artifactId>
>>>>                <configuration>
>>>>                    <systemPropertyVariables>
>>>>
>>>> <CUSTOM_HOME>${project.**basedir}/src/main/config</**CUSTOM_HOME>
>>>>                    </systemPropertyVariables>
>>>>
>>>> <argLine>-Djava.library.path=$**{jniLpSolverLibPath}</argLine>
>>>>                    <excludes>
>>>>                        <exclude>**/UseCaseUnitTest.**java</exclude>
>>>>                    </excludes>
>>>>                </configuration>
>>>>            </plugin>
>>>>        </plugins>
>>>>    </build>
>>>>
>>>> Now, I've added a profile to the POM file, which is the same as the
>>>> default
>>>> setting, but instead the excluded tag is empty.  However, the test is
>>>> always excluded.  No matter how I configure the profile, it always skips
>>>> over the test because it always picks up the original excludes
>>>> definition.
>>>> I've tried defining this in or out of an execution in the profile.
>>>>
>>>>        <profile>
>>>>            <id>tests.allTests</id>
>>>>            <build>
>>>>                <plugins>
>>>>                    <plugin>
>>>>                        <groupId>org.apache.maven.**plugins</groupId>
>>>>                        <artifactId>maven-surefire-**plugin</artifactId>
>>>>                        <configuration>
>>>>                            <excludes/>
>>>>                        </configuration>
>>>>                    </plugin>
>>>>                </plugins>
>>>>            </build>
>>>>        </profile>
>>>>
>>>> This goes against, well, every page and blog entry which tells you this
>>>> should happen.  I'm using version 2.10 of the surefire plugin on mvn
>>>> 3.0.3.  Am I doing something wrong?  Or has this stopped working?  My
>>>> guess
>>>> is I'm doing something not quite right, but I don't know what to do to
>>>> correct this.
>>>>
>>>> Thanks for any help,
>>>> Ed
>>>>
>>>>  ------------------------------**------------------------------**
>>> ---------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<us...@maven.apache.org>
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>  ------------------------------**------------------------------**
>> ---------
>> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<us...@maven.apache.org>
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<us...@maven.apache.org>
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Surefire not behaving the way I expect....

Posted by Kristian Rosenvold <kr...@zenior.no>.
FWIW, surefire 2.11-SNAPSHOT supports the use of JUnit @Categories, 
which I believe a lot of users should be looking at for
including/excluding tests, since it allows you to tag at the 
class/method level and apply multiple include/exclude filters, which 
means you can
cross-cut a much more specific selection on your test-base.

As long as you use junit 4.8 and the surefire 4.7 provider, you can use 
the groups the excludedGroups parameter.

Kristian



Den 17.11.2011 14:46, skrev Benson Margulies:
> Note that I ported this into the formal documentation of the POM as well.
>
> On Thu, Nov 17, 2011 at 2:03 AM, Anders Hammar<an...@hammar.net>  wrote:
>> Try the merge process config explained here:
>> http://www.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/
>>
>> /Anders
>>
>> On Thu, Nov 17, 2011 at 05:52, Ed Hillmann<ed...@gmail.com>  wrote:
>>> Hi.  I have a test which takes a long time to run.  What I'd like to do is
>>> exclude this test (written in JUnit) from the normal test phase, and only
>>> run it when a specific profile is defined.  So, in my pom, I configure the
>>> surefire plugin with an excludes element, which contains the exclude child
>>> element containing the name of the Test to skip.  And, it works great.
>>>
>>>             <plugin>
>>>                 <groupId>org.apache.maven.plugins</groupId>
>>>                 <artifactId>maven-surefire-plugin</artifactId>
>>>                 <configuration>
>>>                     <systemPropertyVariables>
>>>
>>> <CUSTOM_HOME>${project.basedir}/src/main/config</CUSTOM_HOME>
>>>                     </systemPropertyVariables>
>>>
>>> <argLine>-Djava.library.path=${jniLpSolverLibPath}</argLine>
>>>                     <excludes>
>>>                         <exclude>**/UseCaseUnitTest.java</exclude>
>>>                     </excludes>
>>>                 </configuration>
>>>             </plugin>
>>>         </plugins>
>>>     </build>
>>>
>>> Now, I've added a profile to the POM file, which is the same as the default
>>> setting, but instead the excluded tag is empty.  However, the test is
>>> always excluded.  No matter how I configure the profile, it always skips
>>> over the test because it always picks up the original excludes definition.
>>> I've tried defining this in or out of an execution in the profile.
>>>
>>>         <profile>
>>>             <id>tests.allTests</id>
>>>             <build>
>>>                 <plugins>
>>>                     <plugin>
>>>                         <groupId>org.apache.maven.plugins</groupId>
>>>                         <artifactId>maven-surefire-plugin</artifactId>
>>>                         <configuration>
>>>                             <excludes/>
>>>                         </configuration>
>>>                     </plugin>
>>>                 </plugins>
>>>             </build>
>>>         </profile>
>>>
>>> This goes against, well, every page and blog entry which tells you this
>>> should happen.  I'm using version 2.10 of the surefire plugin on mvn
>>> 3.0.3.  Am I doing something wrong?  Or has this stopped working?  My guess
>>> is I'm doing something not quite right, but I don't know what to do to
>>> correct this.
>>>
>>> Thanks for any help,
>>> Ed
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire not behaving the way I expect....

Posted by Benson Margulies <bi...@gmail.com>.
Note that I ported this into the formal documentation of the POM as well.

On Thu, Nov 17, 2011 at 2:03 AM, Anders Hammar <an...@hammar.net> wrote:
> Try the merge process config explained here:
> http://www.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/
>
> /Anders
>
> On Thu, Nov 17, 2011 at 05:52, Ed Hillmann <ed...@gmail.com> wrote:
>> Hi.  I have a test which takes a long time to run.  What I'd like to do is
>> exclude this test (written in JUnit) from the normal test phase, and only
>> run it when a specific profile is defined.  So, in my pom, I configure the
>> surefire plugin with an excludes element, which contains the exclude child
>> element containing the name of the Test to skip.  And, it works great.
>>
>>            <plugin>
>>                <groupId>org.apache.maven.plugins</groupId>
>>                <artifactId>maven-surefire-plugin</artifactId>
>>                <configuration>
>>                    <systemPropertyVariables>
>>
>> <CUSTOM_HOME>${project.basedir}/src/main/config</CUSTOM_HOME>
>>                    </systemPropertyVariables>
>>
>> <argLine>-Djava.library.path=${jniLpSolverLibPath}</argLine>
>>                    <excludes>
>>                        <exclude>**/UseCaseUnitTest.java</exclude>
>>                    </excludes>
>>                </configuration>
>>            </plugin>
>>        </plugins>
>>    </build>
>>
>> Now, I've added a profile to the POM file, which is the same as the default
>> setting, but instead the excluded tag is empty.  However, the test is
>> always excluded.  No matter how I configure the profile, it always skips
>> over the test because it always picks up the original excludes definition.
>> I've tried defining this in or out of an execution in the profile.
>>
>>        <profile>
>>            <id>tests.allTests</id>
>>            <build>
>>                <plugins>
>>                    <plugin>
>>                        <groupId>org.apache.maven.plugins</groupId>
>>                        <artifactId>maven-surefire-plugin</artifactId>
>>                        <configuration>
>>                            <excludes/>
>>                        </configuration>
>>                    </plugin>
>>                </plugins>
>>            </build>
>>        </profile>
>>
>> This goes against, well, every page and blog entry which tells you this
>> should happen.  I'm using version 2.10 of the surefire plugin on mvn
>> 3.0.3.  Am I doing something wrong?  Or has this stopped working?  My guess
>> is I'm doing something not quite right, but I don't know what to do to
>> correct this.
>>
>> Thanks for any help,
>> Ed
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire not behaving the way I expect....

Posted by Anders Hammar <an...@hammar.net>.
Try the merge process config explained here:
http://www.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/

/Anders

On Thu, Nov 17, 2011 at 05:52, Ed Hillmann <ed...@gmail.com> wrote:
> Hi.  I have a test which takes a long time to run.  What I'd like to do is
> exclude this test (written in JUnit) from the normal test phase, and only
> run it when a specific profile is defined.  So, in my pom, I configure the
> surefire plugin with an excludes element, which contains the exclude child
> element containing the name of the Test to skip.  And, it works great.
>
>            <plugin>
>                <groupId>org.apache.maven.plugins</groupId>
>                <artifactId>maven-surefire-plugin</artifactId>
>                <configuration>
>                    <systemPropertyVariables>
>
> <CUSTOM_HOME>${project.basedir}/src/main/config</CUSTOM_HOME>
>                    </systemPropertyVariables>
>
> <argLine>-Djava.library.path=${jniLpSolverLibPath}</argLine>
>                    <excludes>
>                        <exclude>**/UseCaseUnitTest.java</exclude>
>                    </excludes>
>                </configuration>
>            </plugin>
>        </plugins>
>    </build>
>
> Now, I've added a profile to the POM file, which is the same as the default
> setting, but instead the excluded tag is empty.  However, the test is
> always excluded.  No matter how I configure the profile, it always skips
> over the test because it always picks up the original excludes definition.
> I've tried defining this in or out of an execution in the profile.
>
>        <profile>
>            <id>tests.allTests</id>
>            <build>
>                <plugins>
>                    <plugin>
>                        <groupId>org.apache.maven.plugins</groupId>
>                        <artifactId>maven-surefire-plugin</artifactId>
>                        <configuration>
>                            <excludes/>
>                        </configuration>
>                    </plugin>
>                </plugins>
>            </build>
>        </profile>
>
> This goes against, well, every page and blog entry which tells you this
> should happen.  I'm using version 2.10 of the surefire plugin on mvn
> 3.0.3.  Am I doing something wrong?  Or has this stopped working?  My guess
> is I'm doing something not quite right, but I don't know what to do to
> correct this.
>
> Thanks for any help,
> Ed
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org