Class SpecUtil

java.lang.Object
org.spockframework.runtime.SpecUtil

public final class SpecUtil extends Object
Utility methods related to specifications. Particularly useful when integrating Spock with other environments (e.g. Grails).
Author:
Peter Niederwieser
  • Method Details

    • isSpec

      public static boolean isSpec(Class<?> clazz)
      Tells if the given class is a Spock specification. Might return false even though the class implements spock.lang.Specification. This can happen if the class wasn't compiled properly (i.e. Spock's AST transform wasn't run).
    • checkIsSpec

      public static void checkIsSpec(Class<?> clazz)
      Checks if the given class is a Spock specification (according to isSpec()), and throws an InvalidSpecException with a detailed explanation if it is not.
    • isRunnableSpec

      public static boolean isRunnableSpec(Class<?> clazz)
    • checkIsRunnableSpec

      public static void checkIsRunnableSpec(Class<?> clazz)
    • getFeatureCount

      public static int getFeatureCount(Class<?> spec)
      Returns the number of features contained in the given specification. Because Spock allows for the dynamic creation of new features at specification run time, this number is only an estimate.
    • optimizeRunOrder

      public static List<String> optimizeRunOrder(List<String> specNames)
    • getConfiguration

      public static <T> T getConfiguration(Class<T> type)