Package com.tngtech.jgiven.config
Class AbstractJGivenConfiguration
java.lang.Object
com.tngtech.jgiven.config.AbstractJGivenConfiguration
- All Implemented Interfaces:
FormatterConfiguration
- Direct Known Subclasses:
DefaultConfiguration
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
final TagConfiguration.Builder
configureTag
(Class<? extends Annotation> tagAnnotation) Configures the given annotation as a tag.Formatter<?>
getFormatter
(Class<?> typeToBeFormatted) getTagConfiguration
(Class<? extends Annotation> annotationType) void
setAsProvider
(AsProvider asProvider) Set a default interpreter for method names for all items that are subject to this configuration.<T> void
setFormatter
(Class<T> typeToBeFormatted, Formatter<T> formatter) Sets the formatter for the given type.void
setTestClassSuffixRegEx
(String suffixRegEx) Set a regular expression for a test class suffix that should be removed by JGiven in the report.
-
Constructor Details
-
AbstractJGivenConfiguration
public AbstractJGivenConfiguration()
-
-
Method Details
-
configureTag
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
-
setFormatter
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
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
- Specified by:
getFormatter
in interfaceFormatterConfiguration
-
getTestClassSuffixRegEx
-
setAsProvider
Set a default interpreter for method names for all items that are subject to this configuration. Can be overriden byAs
annotation.- See Also:
-
getAsProvider
-