Package com.tngtech.jgiven.config
Class AbstractJGivenConfiguration
- java.lang.Object
-
- com.tngtech.jgiven.config.AbstractJGivenConfiguration
-
- All Implemented Interfaces:
FormatterConfiguration
- Direct Known Subclasses:
DefaultConfiguration
public abstract class AbstractJGivenConfiguration extends java.lang.Object implements FormatterConfiguration
-
-
Constructor Summary
Constructors Constructor Description AbstractJGivenConfiguration()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
configure()
TagConfiguration.Builder
configureTag(java.lang.Class<? extends java.lang.annotation.Annotation> tagAnnotation)
Configures the given annotation as a tag.Formatter<?>
getFormatter(java.lang.Class<?> typeToBeFormatted)
TagConfiguration
getTagConfiguration(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
java.lang.String
getTestClassSuffixRegEx()
<T> void
setFormatter(java.lang.Class<T> typeToBeFormatted, Formatter<T> formatter)
Sets the formatter for the given type.void
setTestClassSuffixRegEx(java.lang.String suffixRegEx)
Set a regular expression for a test class suffix that should be removed by JGiven in the report.
-
-
-
Method Detail
-
configureTag
public final TagConfiguration.Builder configureTag(java.lang.Class<? extends java.lang.annotation.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 theIsTag
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(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
-
setFormatter
public <T> void setFormatter(java.lang.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,
ThenformatterB
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 eitherformatterA
orformatterB
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 definedformatter
- the formatter to format instances of that type
-
setTestClassSuffixRegEx
public void setTestClassSuffixRegEx(java.lang.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(java.lang.Class<?> typeToBeFormatted)
- Specified by:
getFormatter
in interfaceFormatterConfiguration
-
getTestClassSuffixRegEx
public java.lang.String getTestClassSuffixRegEx()
-
-