You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leif Mortenson <le...@silveregg.co.jp> on 2002/01/24 05:20:48 UTC

Re: [VOTE] modify build.xml to use JUnitReport for tests

Peter Donald wrote:

>On Thu, 24 Jan 2002 14:18, Leif Mortenson wrote:
>
>>If you run build test on Excalibur, the output can be a little
>>overwhelming. It is not easy to get a feel for the overall state of the
>>project without looking over each test result one by one, making sure
>>that they passed.
>>
>>Luckily ant has the JunitReport task, which creates a beautiful set of
>>html reports clearly showing the results of the test suite.
>>
>>I wanted to ask before making this change because it would require that
>>the test outfiles be changed from text files to xml files.
>>
>>I'll start with my +1
>>
>
>I would prefer to have at least the option to do text reports. The main 
>reason is I tend to run the tests from inside the editor and it is far easer 
>to tell which things are working or not while developing a particular 
>package. So maybe we could add  a property "build.xml-reports" or something 
>to determine which version we run.
>
>Alternatively we could have a "single test target" which only tests a single 
>junit class (passed in from command line via 
>-Djunit.test=org.excalibur.MyTest) and uses the text formatter?
>
>Or something else?
>
>Thoughts?
>

Glad I asked then.  It looks like like the junit task allows you to 
specify two formatters.
So I can make it output both text and xml reports.

As I was adding that though I realized that there is already another 
task called
test-reports which already does this.  How would you feel about removing 
the test-reports
task in favor of the method above to reduce code duplication?

If there is concern about the clutter caused by both text and xml files 
being in the reports
directory, that problem could be solved by deleting the test xml files 
after the junittest
task has completed.


I like the idea of being able to run individual tests, so I added a new 
task test-subset
which expects a property junit.test for the test(s) to be run.

I'm including the diff of that.

Opinions?

Leif

cvs -z3 diff build.xml (in directory E:\Jakarta\jakarta-avalon-excalibur\)
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/build.xml,v
retrieving revision 1.88
diff -r1.88 build.xml
302c302,303
<       <formatter type="plain"/>
---
 >       <formatter type="xml"/>    <!-- xml reports for junitreport -->
 >       <formatter type="plain"/>  <!-- text reports for humans     -->
327c328,359
<
---
 >        
 >     <junitreport todir="${build.reports}">
 >       <fileset dir="${build.reports}">
 >         <include name="TEST-*.xml"/>
 >       </fileset>
 >       <report format="frames" todir="${build.reports}/html"/>
 >     </junitreport>
 >   </target>
 >    
 >   <target name="test-subset-check" unless="junit.test">
 >     <fail message="junit.test not specified.  Example usage: build 
test-subset -Djunit.test=**/ResourceLimiting*TestCase.class" />
 >   </target>
 >    
 >   <target name="test-subset" depends="test-subset-check, compile" 
description="perferm a subset of unit tests">
 >     <mkdir dir="${build.reports}"/>
 >    
 >     <junit fork="true" printsummary="yes" dir="${build.reports}">
 >       <formatter type="plain"/>  <!-- text reports for humans     -->
 >       <classpath>
 >         <path refid="test.class.path"/>
 >         <pathelement location="${build.classes}"/>
 >         <pathelement location="${build.scratchpad}"/>
 >       </classpath>
 >       <batchtest todir="${build.reports}">
 >         <fileset dir="${build.classes}">
 >           <include name="${junit.test}"/>
 >         </fileset>
 >         <fileset dir="${build.scratchpad}">
 >           <include name="${junit.test}"/>
 >         </fileset>
 >       </batchtest>
 >     </junit>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [VOTE] modify build.xml to use JUnitReport for tests

Posted by Berin Loritsch <bl...@apache.org>.
Leif Mortenson wrote:

> Peter Donald wrote:
> 
>> On Thu, 24 Jan 2002 14:18, Leif Mortenson wrote:
>>
>>> If you run build test on Excalibur, the output can be a little
>>> overwhelming. It is not easy to get a feel for the overall state of the
>>> project without looking over each test result one by one, making sure
>>> that they passed.
>>>
>>> Luckily ant has the JunitReport task, which creates a beautiful set of
>>> html reports clearly showing the results of the test suite.
>>>
>>> I wanted to ask before making this change because it would require that
>>> the test outfiles be changed from text files to xml files.
>>>
>>> I'll start with my +1
>>>
>>
>> I would prefer to have at least the option to do text reports. The 
>> main reason is I tend to run the tests from inside the editor and it 
>> is far easer to tell which things are working or not while developing 
>> a particular package. So maybe we could add  a property 
>> "build.xml-reports" or something to determine which version we run.
>>



There is already an entry for that in all the framework, excalibur, and
logkit build scripts.  The target is "test-report"

Just type

$ ant test-report

and the results will be generated in the following directory:

${excalibur}/build/docs/test/test

(it should be just one test directory, so that part needs to be fixed).


-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [VOTE] modify build.xml to use JUnitReport for tests

Posted by Peter Donald <pe...@apache.org>.
On Fri, 25 Jan 2002 15:58, Leif Mortenson wrote:
> Ok, I went ahead and added a new task called test-subset which lets you
> run individual or subsets of tests.  The syntax looks like this:
>
> build -Djunit.test=**/ResourceLimiting*TestCase.class test-subset
>
> I also merged the test and test-report tasks into a single task.  They
> were testing different things because people had not been modifying both
> of them over time.
> The way it is now, the test reports are always generated by the test
> task, but the TEST-*.xml files are deleted to remove clutter.

excellente!!!

You both write tests and make sure they run - great addition to Avalon I 
think ;)

> When I was merging the tasks, I noticed that the test task was excluding
> the following tests, while the test-report task was not.  Currently this
> code is commented out so they always run.
>
>          <exclude
> name="org/apache/avalon/excalibur/naming/rmi/test/RMIContextTestCase.class"
>/>
>
>          <exclude
> name="org/apache/avalon/excalibur/logger/test/LogKitManagementTestCase.clas
>s"/>
>
>          <exclude
> name="org/apache/avalon/excalibur/concurrent/test/ReadWriteLockTestCase.cla
>ss"/>
>
>          <exclude
> name="org/apache/avalon/excalibur/monitor/test/MonitorTestCase.class"/>

Im not sure why they are disabled - feel free to re-enable them. They may 
have been temporarily disabled while someone was testing a component (because 
thye take a long time or something) and they forgot to get re-enabled.

-- 
Cheers,

Pete

-----------------------------------------------------------
 Don't take life too seriously -- 
                          you'll never get out of it alive.
-----------------------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [VOTE] modify build.xml to use JUnitReport for tests

Posted by Leif Mortenson <le...@silveregg.co.jp>.
Berin Loritsch wrote:

> Leif Mortenson wrote:
> 
>> Ok, I went ahead and added a new task called test-subset which lets 
>> you run individual or subsets of tests.  The syntax looks like this:
>>
>> build -Djunit.test=**/ResourceLimiting*TestCase.class test-subset
> 
> Did you get the mail I had that had the junit-report tag?


Yes, I saw it but I had not realized that the differences in what was 
being tested in the 'check' and 'test-report' tasks was intentional and 
took the opportunity to reduce duplicate code.

Ok, I modified the build so that it will now run all the tests when you 
do a build dist.  And only the fast tests when you run build check. 
Take a look and see if this works for you.  It uses the unless attribute 
to avoid duplicating code.


I am having one problem with the junitreport task however.  It works 
fine on my work machine, but on my home machine (W2K), junitreport is 
saying that two of the xml reports are corrupted.

Here is the error I am getting.
---
The file 
C:\Jakarta\jakarta-avalon-excalibur\build\reports\TEST-org.apache.avalon.excalibur.pool.test.ResourceLimitingPoolMultithreadMaxStrictTestCase.xml 
is not a valid XML document. It is possibly corrupted.
The file 
C:\Jakarta\jakarta-avalon-excalibur\build\reports\TEST-org.apache.avalon.excalibur.pool.test.ResourceLimitingPoolMultithreadMaxTestCase.xml 
is not a valid XML document. It is possibly corrupted.
---

This does not break the build, the two tests just do not show up in the 
HTML reports.

Running with debug on, you can see the cause:
org.xml.sax.SAXParseException: Attribute "time" was already specified 
for element "testcase".

Being caused by xml like:
   <testcase name="testGetPut" time="0.032" time="0.032"></testcase>

This looks like a bug in the ant junit task.


Let me know how you feel about these changes.
Cheers,
Leif



>> I also merged the test and test-report tasks into a single task.  They 
>> were testing different things because people had not been modifying 
>> both of them over time.
> 
> 
> 
> No, they were testing different things because the test task was meant to
> be a *quick* sanity check, and the test-report task was meant to be 
> included
> in the documentation.
> 
> 
>> The way it is now, the test reports are always generated by the test 
>> task, but the TEST-*.xml files are deleted to remove clutter.
>>
>> When I was merging the tasks, I noticed that the test task was 
>> excluding the following tests, while the test-report task was not.  
>> Currently this code is commented out so they always run.
>>
>>         <exclude 
>> name="org/apache/avalon/excalibur/naming/rmi/test/RMIContextTestCase.class"/> 
>>
>>         <exclude 
>> name="org/apache/avalon/excalibur/logger/test/LogKitManagementTestCase.class"/> 
>>
>>         <exclude 
>> name="org/apache/avalon/excalibur/concurrent/test/ReadWriteLockTestCase.class"/> 
>>
>>         <exclude 
>> name="org/apache/avalon/excalibur/monitor/test/MonitorTestCase.class"/>
> 
> 
> 
> It is because those tests take a while to perform.  The test/check task was
> meant completely as a quick sanity test so developers could do:
> 
> $ant clean all check
> 
> The longer tests make it difficult to keep up your train of thought when 
> you
> are developing.  This was Peter's idea.
> 
> 
> 
>> Right now there is 1 failure in the 
>> org.apache.avalon.excalibur.monitor.test package and 2 errors in the 
>> org.apache.avalon.excalibur.i18n.test package.
> 
> 
> 
> I have worked long and hard to make the monitor test to always work--the
> problem is that the test is timing out before the JVM has a chance to
> propogate the PropertyChangeEvent to all it's listeners.  I have been
> meaning to take control from the PropertyChange utility class in the JVM
> and do it myself explicitly.  The utility takes too long.
> 
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [VOTE] modify build.xml to use JUnitReport for tests

Posted by Berin Loritsch <bl...@apache.org>.
Leif Mortenson wrote:

> Ok, I went ahead and added a new task called test-subset which lets you 
> run individual or subsets of tests.  The syntax looks like this:
> 
> build -Djunit.test=**/ResourceLimiting*TestCase.class test-subset


Did you get the mail I had that had the junit-report tag?



> I also merged the test and test-report tasks into a single task.  They 
> were testing different things because people had not been modifying both 
> of them over time.


No, they were testing different things because the test task was meant to
be a *quick* sanity check, and the test-report task was meant to be included
in the documentation.


> The way it is now, the test reports are always generated by the test 
> task, but the TEST-*.xml files are deleted to remove clutter.
> 
> When I was merging the tasks, I noticed that the test task was excluding 
> the following tests, while the test-report task was not.  Currently this 
> code is commented out so they always run.
> 
>         <exclude 
> name="org/apache/avalon/excalibur/naming/rmi/test/RMIContextTestCase.class"/> 
> 
>         <exclude 
> name="org/apache/avalon/excalibur/logger/test/LogKitManagementTestCase.class"/> 
> 
>         <exclude 
> name="org/apache/avalon/excalibur/concurrent/test/ReadWriteLockTestCase.class"/> 
> 
>         <exclude 
> name="org/apache/avalon/excalibur/monitor/test/MonitorTestCase.class"/>


It is because those tests take a while to perform.  The test/check task was
meant completely as a quick sanity test so developers could do:

$ant clean all check

The longer tests make it difficult to keep up your train of thought when you
are developing.  This was Peter's idea.



> Right now there is 1 failure in the 
> org.apache.avalon.excalibur.monitor.test package and 2 errors in the 
> org.apache.avalon.excalibur.i18n.test package.


I have worked long and hard to make the monitor test to always work--the
problem is that the test is timing out before the JVM has a chance to
propogate the PropertyChangeEvent to all it's listeners.  I have been
meaning to take control from the PropertyChange utility class in the JVM
and do it myself explicitly.  The utility takes too long.



-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [VOTE] modify build.xml to use JUnitReport for tests

Posted by Leif Mortenson <le...@silveregg.co.jp>.
Ok, I went ahead and added a new task called test-subset which lets you 
run individual or subsets of tests.  The syntax looks like this:

build -Djunit.test=**/ResourceLimiting*TestCase.class test-subset

I also merged the test and test-report tasks into a single task.  They 
were testing different things because people had not been modifying both 
of them over time.
The way it is now, the test reports are always generated by the test 
task, but the TEST-*.xml files are deleted to remove clutter.

When I was merging the tasks, I noticed that the test task was excluding 
the following tests, while the test-report task was not.  Currently this 
code is commented out so they always run.

         <exclude 
name="org/apache/avalon/excalibur/naming/rmi/test/RMIContextTestCase.class"/> 

         <exclude 
name="org/apache/avalon/excalibur/logger/test/LogKitManagementTestCase.class"/> 

         <exclude 
name="org/apache/avalon/excalibur/concurrent/test/ReadWriteLockTestCase.class"/> 

         <exclude 
name="org/apache/avalon/excalibur/monitor/test/MonitorTestCase.class"/>

Right now there is 1 failure in the 
org.apache.avalon.excalibur.monitor.test package and 2 errors in the 
org.apache.avalon.excalibur.i18n.test package.

Cheers,
Leif

Peter Donald wrote:

>On Thu, 24 Jan 2002 15:20, Leif Mortenson wrote:
>
>>Glad I asked then.  It looks like like the junit task allows you to
>>specify two formatters.
>>So I can make it output both text and xml reports.
>>
>>As I was adding that though I realized that there is already another
>>task called
>>test-reports which already does this.  How would you feel about removing
>>the test-reports
>>task in favor of the method above to reduce code duplication?
>>
>>If there is concern about the clutter caused by both text and xml files
>>being in the reports
>>directory, that problem could be solved by deleting the test xml files
>>after the junittest
>>task has completed.
>>
>>
>>I like the idea of being able to run individual tests, so I added a new
>>task test-subset
>>which expects a property junit.test for the test(s) to be run.
>>
>>I'm including the diff of that.
>>
>>Opinions?
>>
>
>+1 - go for it ;)
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [VOTE] modify build.xml to use JUnitReport for tests

Posted by Peter Donald <pe...@apache.org>.
On Thu, 24 Jan 2002 15:20, Leif Mortenson wrote:
> Glad I asked then.  It looks like like the junit task allows you to
> specify two formatters.
> So I can make it output both text and xml reports.
>
> As I was adding that though I realized that there is already another
> task called
> test-reports which already does this.  How would you feel about removing
> the test-reports
> task in favor of the method above to reduce code duplication?
>
> If there is concern about the clutter caused by both text and xml files
> being in the reports
> directory, that problem could be solved by deleting the test xml files
> after the junittest
> task has completed.
>
>
> I like the idea of being able to run individual tests, so I added a new
> task test-subset
> which expects a property junit.test for the test(s) to be run.
>
> I'm including the diff of that.
>
> Opinions?

+1 - go for it ;)

-- 
Cheers,

Pete

----------------------------------------------
Money is how people with no talent keep score.
----------------------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>