You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Jack, Paul" <pj...@sfaf.org> on 2002/05/31 02:47:27 UTC

[PATCH][Collections] New testing framework, patch #1

Okay, so the goal was to be able to modularize the 
tests in such a way that objects that return a collection
or map could have those return values tested using
TestMap, TestCollection etc.

How I decided to handle that was to create a new
implementation of junit.framework.Test, that allows
you to specify "bulk test" methods in addition to
the usual simple test methods:

   public BulkTest bulkTestListSubList() {
       return new TestList() {
           public List makeFullList() {
               return outer.makeFullList().subList(2, 12);
           }

           public BulkTest bulkTestSubList() {
               return null; // avoid recursion
           }
       };
   }

The above example would be used to run through ALL of
the tests defined by TestList on its sublists...

A similar approach will be used for Maps and their
collection views.

This patch contains:

1.  The code for the new BulkTest class.
2.  Patch for TestObject to make it extend BulkTest
instead of TestCase.
3.  Patches for almost all of the classes, to replace
their suite() methods.  TestSuite knows nothing about
bulk test methods, so it can't be used.

After this patch, all existing tests still work.

Upcoming patches will have versions of TestList and
TestMap that utilize bulk test methods for their 
subcollections.

-Paul



Re: [PATCH][Collections] New testing framework, patch #1

Posted by "Michael A. Smith" <ma...@apache.org>.
Sorry its taken so long to review your patches.  Now that I've had the 
chance, I wish I was able to take a look sooner. 

On Thu, 30 May 2002, Jack, Paul wrote:
> Okay, so the goal was to be able to modularize the 
> tests in such a way that objects that return a collection
> or map could have those return values tested using
> TestMap, TestCollection etc.

right.

> How I decided to handle that was to create a new
> implementation of junit.framework.Test, that allows
> you to specify "bulk test" methods in addition to
> the usual simple test methods:

I'm agreeing with your intent here (i.e. the addition of the bulk test
methods), however I disagree with reimplementing Test.  My main
objection is that you are reimplementing parts of JUnit and missing some
of the functionality that it provided.  Namely, the ability to extract
the testing hierarchy.

While the hierarchy isn't readily visible when run using the textui (the 
junit test runner that's run automatically as part of the commons 
build), it is useful to have when using JUnit's swing UI.  I'd really 
like to be able to see a hierarchy that looks something like this:

 TestAll
   TestArrayIterator
   ...
   TestSequencedHashMap
     testMapGet
     ...
     testYoungest
     testYoungestReplaceNullWithValue
     entrySet
       testSize
       testFoo
       testBar
     keySet
       testSize
       testFoo
       testBar
     ...
   TestFastArrayList
     testSearch
     testNewArrayList
     subList
       testFoo
       testBar

You've put a lot of work into getting these tests up and running, and it
has exposed some problems with existing implementations, so your work
isn't without merit.  In fact, I'm inclined to commit it, I would just
rather see something that utilizes JUnit's TestSuite (by subclass
probably since it doesn't support "bulkTest") so that a proper test
hierarchy can be built.  Therefore, I'm going to hold off a little bit 
to see if any other collections committers care to comment on the above.  

regards,
michael


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