You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Peter Nordlund <pe...@lentus.se> on 2000/09/21 16:39:26 UTC

Re: Property dir in junit task fails. (Was Re: property dir needed in java and junit tasks)

Stefan Bodewig wrote:
> 
> >>>>> "PN" == Peter Nordlund <pe...@lentus.se> writes:
> 
>  PN> Ok, my problem is that I want to run the testsuite, "all my
>  PN> junit-tests" (the tests must be executed in different
>  PN> directories) and get a total summary of it all in ONE SINGLE
>  PN> result file.
> 
> Now _that_ would be useful, but it is plain impossible right now as
> you can only specify the name of a resultfile on a test by test basis
> - and the file would be overwritten for each test.
> 
> I'd like to change that bit, allow users to specify a filename and use
> that for all testresults - probably as an argument to <formatter>. Now
> you'd need a way to append to this file in another run and you are
> done, right?

Yes, I think so.

> 
> <target>
>   <delete file="testresults.txt" />
>   <junit dir="dir1">
>     <formatter type="plain" outfile="testresults" />
>   </junit>
>   <junit dir="dir2">
>     <formatter type="plain" outfile="testresults" append="true" />
>   </junit>
> </target>
> 
> What do you think?
> 
> Stefan

My reflection on your proposal is: now the result-file is
sort of getting outside the junit-task. I don't know if that is
a problem or not.
Also I get a feeling that you need to duplicate some code, or
is there a way to reuse junit-tasks already defined?

I guess the question you have to ask yourself is:
Should this kind of functionality be kept inside one single
junit-task or not.

Maybe my original proposal wasn't the best...
For "run all tests" you probably also have different
classpaths also, not only different execution directories. 
This would mean that the
test and batchtest nested elements also should take a classpath.
test and batchtest would probably grow in complexity then....


--------
Maybe something like this would work?
(but I have a feeling that calling ant recursively and changing
exec-dirs
is not working as I expect it to do... I have not investigated it
carefully, but I think I got surprising result when I tried it some time
ago.)

<target name="alltests">
   <delete file="testresults.txt" />
   <ant target="junit1, junit2">
     <!-- Overide the original formatter -->
     <formatter type="plain" outfile="testresults" append="true" />
   </ant>
 </target>

------------

* What I guess would be the best solution comes here:
Is there a way to reuse tasks with "ids" and "refids" in some way?
Something like:

 <target name="alltests">
   <delete file="testresults.txt" />
   <!-- Overide the original formatter -->
   <formatter type="plain" outfile="testresults" append="true" />
   <junit refid="junit1id" />
   <junit refid="junit2id" />
   </ant>
 </target>


Now I am going abroad for a few days so I can't reply to
this discussion for a while, see you later!

/Peter

Re: Property dir in junit task fails. (Was Re: property dir needed in java and junit tasks)

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "PN" == Peter Nordlund <pe...@lentus.se> writes:

 PN> My reflection on your proposal is: now the result-file is sort of
 PN> getting outside the junit-task. I don't know if that is a problem
 PN> or not.  Also I get a feeling that you need to duplicate some
 PN> code, or is there a way to reuse junit-tasks already defined?

Not the whole task, but I guess you wouldn't need to put too many
common things into them. The classpath could be reused by reference.

The append attribute would make the file external to the <junit> task,
that's true. Don't actually know whether this could be a problem. But
as it stands, there is currently no way to get all test results into a
single file (no matter if you are using a single task or several).

 PN> Now I am going abroad for a few days so I can't reply to this
 PN> discussion for a while, see you later!

Same here.

Stefan