Class AbstractJGivenConfiguration

java.lang.Object
com.tngtech.jgiven.config.AbstractJGivenConfiguration
All Implemented Interfaces:
FormatterConfiguration
Direct Known Subclasses:
DefaultConfiguration

public abstract class AbstractJGivenConfiguration extends Object implements FormatterConfiguration
  • Constructor Details

    • AbstractJGivenConfiguration

      public AbstractJGivenConfiguration()
  • Method Details

    • configureTag

      public final TagConfiguration.Builder configureTag(Class<? extends Annotation> tagAnnotation)
      Configures the given annotation as a tag. This is useful if you want to treat annotations as tags in JGiven that you cannot or want not to be annotated with the IsTag annotation.
      Parameters:
      tagAnnotation - the tag to be configured
      Returns:
      a configuration builder for configuring the tag
    • configure

      public abstract void configure()
    • getTagConfiguration

      public TagConfiguration getTagConfiguration(Class<? extends Annotation> annotationType)
    • setFormatter

      public <T> void setFormatter(Class<T> typeToBeFormatted, Formatter<T> formatter)
      Sets the formatter for the given type.

      When choosing a formatter, JGiven will take the formatter defined for the most specific super type of a given type.

      If no formatter can be found for a type, the DefaultFormatter is taken.

      For example, given the following formatter are defined:

       setFormatter( Object.class, formatterA );
       setFormatter( String.class, formatterB );
       
      When formatting a String,
      Then formatterB will be taken.

      If formatter for multiple super types of a type are defined, but these types have no subtype relation, then an arbitrary formatter is taken in a non-deterministic way. Thus you should avoid this situation.

      For example, given the following formatter are defined:

       setFormatter( Cloneable.class, formatterA );
       setFormatter( Serializable.class, formatterB );
       
      When formatting a String,
      Then either formatterA or formatterB will be taken non-deterministically.

      The order in which the formatter are defined, does not make a difference.

      Note that the formatter can still be overridden by using a formatting annotation.

      Parameters:
      typeToBeFormatted - the type for which the formatter should be defined
      formatter - the formatter to format instances of that type
    • setTestClassSuffixRegEx

      public void setTestClassSuffixRegEx(String suffixRegEx)
      Set a regular expression for a test class suffix that should be removed by JGiven in the report.

      By default the regular expression is Tests?

      Parameters:
      suffixRegEx - a regular expression that match the suffix
    • getFormatter

      public Formatter<?> getFormatter(Class<?> typeToBeFormatted)
      Specified by:
      getFormatter in interface FormatterConfiguration
    • getTestClassSuffixRegEx

      public String getTestClassSuffixRegEx()
    • setAsProvider

      public void setAsProvider(AsProvider asProvider)
      Set a default interpreter for method names for all items that are subject to this configuration. Can be overriden by As annotation.
      See Also:
    • getAsProvider

      public AsProvider getAsProvider()