You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Josip Gracin <gr...@veeone.tel.fer.hr> on 2004/06/27 10:52:48 UTC

Howto exclude some tests from within maven.xml

Hello!

How can I modify the maven.test.compile.src.set from within
maven.xml?  What I need to do is the following: 
when there is some property set, additional unit tests should
be included, otherwise, everything should be run
without those tests.

It's about acceptance tests.  I need to be able to run
maven without acceptance tests but if I defined some
system property, then acceptance tests should also be run.
The acceptance tests are also unit tests which are located 
in the same directory where all other unit tests.

I tryed modifying maven.test.compile.src.set, but I couldn't
get it to work.  Was that the right way to do it?

Thanks!

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


Re: Howto exclude some tests from within maven.xml

Posted by Josip Gracin <gr...@tel.fer.hr>.
On Tuesday 29 June 2004 16:56, Josip Gracin wrote:
> > In the above debug, com/ingemark/articlebook/** is included and
> > excluded. I don't think you want to do both....
>
> Well, actually, I do.  Sort of.  Because I have all unit tests in one
> source tree, and I want only some of the tests to be run by default, and
> the rest of the tests included only if some property is set.

... and what you see is the result of modifying test includes from within 
maven.xml even though excludes were set in project.xml.


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


Re: Howto exclude some tests from within maven.xml

Posted by Josip Gracin <gr...@tel.fer.hr>.
At 17:18 29-06-04, you wrote:
>On Tue, 29 Jun 2004 16:56:38 +0200, Josip Gracin <gr...@tel.fer.hr> wrote:
>
> > To repeat my original question: is there a way to dynamically (from 
> maven.xml)
> > add a set of tests which normally wouldn't be run?
>You're doing half of it by the looks.
>
>You're adding it to the includes, but not removing it from the excludes.

Yes, I became aware of that after your previous mail.  That's why I repeated
the original question.  Thanks.


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


Re: Howto exclude some tests from within maven.xml

Posted by Dion Gillard <di...@gmail.com>.
On Tue, 29 Jun 2004 16:56:38 +0200, Josip Gracin <gr...@tel.fer.hr> wrote:

> To repeat my original question: is there a way to dynamically (from maven.xml)
> add a set of tests which normally wouldn't be run?
You're doing half of it by the looks.

You're adding it to the includes, but not removing it from the excludes.

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


Re: Howto exclude some tests from within maven.xml

Posted by Josip Gracin <gr...@tel.fer.hr>.
On Tuesday 29 June 2004 16:43, Dion Gillard wrote:
> On Tue, 29 Jun 2004 16:33:24 +0200, Josip Gracin <gr...@tel.fer.hr> wrote:
> >     [junit] [DEBUG] fileset: Setup scanner in dir C:\ing\bits-ci\test
> > with patternSet{ includes: [com/ingemark/articlebook/**] excludes:
> > [com/ingemark/articlebook/**, **/*AbstractTestCase.java] }
>
> In the above debug, com/ingemark/articlebook/** is included and
> excluded. I don't think you want to do both....

Well, actually, I do.  Sort of.  Because I have all unit tests in one source 
tree, and I want only some of the tests to be run by default, and the rest of 
the tests included only if some property is set.

To repeat my original question: is there a way to dynamically (from maven.xml) 
add a set of tests which normally wouldn't be run?


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


Re: Howto exclude some tests from within maven.xml

Posted by Dion Gillard <di...@gmail.com>.
On Tue, 29 Jun 2004 16:33:24 +0200, Josip Gracin <gr...@tel.fer.hr> wrote:
[snip]
>     [junit] [DEBUG] fileset: Setup scanner in dir C:\ing\bits-ci\test with
> patternSet{ includes: [com/ingemark/articlebook/**] excludes:
> [com/ingemark/articlebook/**, **/*AbstractTestCase.java] }
[snip]
> For some reason, calling this method aborts any further execution of the goals
> in test plugin.  Any ideas?


In the above debug, com/ingemark/articlebook/** is included and
excluded. I don't think you want to do both....

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


Re: Howto exclude some tests from within maven.xml

Posted by Josip Gracin <gr...@tel.fer.hr>.
Hello Brett!  Thanks for a thorough answer.  I've been trying your suggestions 
for the last two days but I couldn't get any of them to work.

On Monday 28 June 2004 04:24, Brett Porter wrote:
> BUT you don't seem to be modifying the source set - instead you want
> to change the tests that are run? ....... you
> probably just want to do something like:
>
> ${pom.unitTest.includes.add('**/FooTest.java')}

I have tryed that and the same thing with pom.build.unitTest.includes which is 
probably what you meant, isn't it?  But a new problem came up.  The following 
is (more or less) exactly what I have as a preGoal:

<preGoal name="test:test">
	${pom.build.unitTest.includes.add('com/company/package/**')}
</preGoal>

Now, when I run 'maven test' this is the output:

 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0-rc3

build:start:

java:prepare-filesystem:

java:compile:
    [echo] Compiling to .../target/classes
tjdo:init:

tjdo:enhance:
    [echo] JDO-enhancing classes for Triactive JDO
    [echo] Classes are now JDO-enhanced for Triactive JDO
BUILD SUCCESSFUL
Total time: 4 seconds
Finished at: Tue Jun 29 16:18:43 CEST 2004


Note that the test goal doesn't seem to be executed at all.  And this is 
because of calling ${pom.build.unitTest.includes.add()}.

And with 'maven -X test', in the end I get the following:

...... a lot of stuff cut ......

test:test:
true    [taskdef] [DEBUG] Class 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask loaded from parent 
loader
    [taskdef] [DEBUG]  +User task: junit     
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask
[DEBUG] Found /C:/Documents and 
Settings/josko/.maven/repository/junit/jars/junit-3.8.1.jar
[DEBUG] Found /C:/ing/maven-1.0-rc3/lib/ant-1.5.3-1.jar
[DEBUG] Found /C:/ing/maven-1.0-rc3/lib/ant-optional-1.5.3-1.jar
    [junit] [DEBUG] fileset: Setup scanner in dir C:\ing\bits-ci\test with 
patternSet{ includes: [com/ingemark/articlebook/**] excludes: 
[com/ingemark/articlebook/**, **/*AbstractTestCase.java] }
attaining goal build:end
BUILD SUCCESSFUL
Final Memory: 3M/5M
Total time: 4 seconds
Finished at: Tue Jun 29 16:10:18 CEST 2004


Note the 'true' in the second line.  This 'true' is produced by executing 
${pom.build.unitTest.includes.add()}.  I have tryed encapsulating it in <j:if 
test="${pom.build.....}"/> but still the same.

For some reason, calling this method aborts any further execution of the goals 
in test plugin.  Any ideas?


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


Re: Howto exclude some tests from within maven.xml

Posted by Brett Porter <br...@gmail.com>.
In general, 

<maven:set plugin="maven-test-plugin" property="foo" value="bar" />

>From RC3 is a better way to do this.

HOWEVER - *.src.set is an ant path, so you should use  the
<maven:addPath /> to add source directories to the source path. See
the jelly tag documentation.

BUT you don't seem to be modifying the source set - instead you want
to change the tests that are run? There is an issue (MAVEN-515 I
think) raised to add this enhancement in the long run, but you
probably just want to do something like:

${pom.unitTest.includes.add('**/FooTest.java')}

(completely untested, but should work).

Cheers,
Brett

On Sun, 27 Jun 2004 18:54:35 -0700, matthew.hawthorne <ma...@apache.org> wrote:
> 
> Josip Gracin wrote:
> > How can I modify the maven.test.compile.src.set from within
> > maven.xml?  What I need to do is the following:
> > when there is some property set, additional unit tests should
> > be included, otherwise, everything should be run
> > without those tests.
> >
> > I tryed modifying maven.test.compile.src.set, but I couldn't
> > get it to work.  Was that the right way to do it?
> 
> 
> You may have to do something like this:
> 
> {pom.getPluginContext('maven-test-plugin').setVariable('maven.test.compile.src.set',
> 'yourDirectory')}
> 
> I've done it a few times but I don't have the files anymore.  You may
> need to debug by outputting the property values in preGoals or postGoals
> to test:compile, or something like that.
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Howto exclude some tests from within maven.xml

Posted by "matthew.hawthorne" <ma...@apache.org>.
Josip Gracin wrote:
> How can I modify the maven.test.compile.src.set from within
> maven.xml?  What I need to do is the following: 
> when there is some property set, additional unit tests should
> be included, otherwise, everything should be run
> without those tests.
> 
> I tryed modifying maven.test.compile.src.set, but I couldn't
> get it to work.  Was that the right way to do it?


You may have to do something like this:

{pom.getPluginContext('maven-test-plugin').setVariable('maven.test.compile.src.set', 
'yourDirectory')}

I've done it a few times but I don't have the files anymore.  You may 
need to debug by outputting the property values in preGoals or postGoals 
to test:compile, or something like that.

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