Re: extension request on org.junit.internal.MethodSorter

David Saff <[email protected]> Tue, 3 Dec 2013 16:06:31 -0500
Newsgroups gmane.comp.java.junit.user
Message-ID <CALrw-PwNALLvZXgtMPP=39tFnKN+75nTAhV3NP2soLAGQqTH6g@mail.gmail.com>
ikedumike,

Thanks for your long use and support!

I think that allowing pseudo-random sorting sounds like a good extension.
 I'd rather not use MethodSorter to do that, however, because it's limited
to methods in classes, and only for certain runners.  For example, it
wouldn't allow randomizing classes within a suite.  MethodSorter was
created merely to enable a workaround for people who found their
method-order changing as a result of upgrading from JDK 6 to JDK 7

There's an existing Sorter abstraction that I think would work well for
this.  One way to make it generally useful might be to make ParentRunner
recognize a @SortWith annotation that would provide a Sorter, either one
like this, or any other kind of Sorter.

   David Saff


On Tue, Dec 3, 2013 at 2:30 PM, <[email protected]> wrote:

>
>
> Hi Mathew and David
>
> Having used Junit with great pleasure inside the eighth largest software
> organization in the world during many years I would like to ask you to add
> an method sorter extension to org.junit.internal.MethodSorter.
>
> It looks like:
>
>     /**
>      * Linear congruential pseudorandom number sort order, with
>      * {@link Random#nextInt(int) } as a tiebreaker
>      */
>     public static Comparator<Method> PSUEDO_RANDOM = new
> Comparator<Method>() {
>         public int compare(Method m1, Method m2) {
>             final int nextInt = randomizer.nextInt(2);
>             return nextInt == 0 ? -1 : 1;
>         }
>     };
>
> I can submit the full code sample with Junit test cases somewhere. It
> would be a great addon in junit since there are many developers that
> sometimes forget that it is a bad idea to create test classes where the
> testmethods depend on each other. TestNG has this feature. This addon would
> make Junit standout better in feature comparisions.
>
> Look forward to hearing from you soon.
>
> Regards
>
> Long time user and promoter of Junit
>
> - ikedumike
>
>  
>