Class ClassOrderer.Default

java.lang.Object
org.junit.jupiter.api.ClassOrderer.Default
All Implemented Interfaces:
ClassOrderer
Enclosing interface:
ClassOrderer

@API(status=EXPERIMENTAL, since="6.0") public static final class ClassOrderer.Default extends Object implements ClassOrderer
ClassOrderer that allows to explicitly specify that the default ordering should be applied.

If the "junit.jupiter.testclass.order.default" is set, specifying this ClassOrderer has the same effect as referencing the configured class directly. Otherwise, it has the same effect as not specifying any ClassOrderer.

This class can be used to reset the ClassOrderer for a @Nested class and its @Nested inner classes, recursively, when a ClassOrderer is configured using @TestClassOrder on an enclosing class.

Since:
6.0
  • Method Details

    • orderClasses

      public void orderClasses(ClassOrdererContext context)
      Description copied from interface: ClassOrderer
      Order the classes encapsulated in the supplied ClassOrdererContext.

      The classes to order or sort are made indirectly available via ClassOrdererContext.getClassDescriptors(). Since this method has a void return type, the list of class descriptors must be modified directly.

      For example, a simplified implementation of the ClassOrderer.Random ClassOrderer might look like the following.

       public void orderClasses(ClassOrdererContext context) {
           Collections.shuffle(context.getClassDescriptors());
       }
      Specified by:
      orderClasses in interface ClassOrderer
      Parameters:
      context - the ClassOrdererContext containing the class descriptors to order; never null