doc / ch.tutteli.atrium.assertions.builders / AssertionBuilder

AssertionBuilder

interface AssertionBuilder (source)

Represents a builder which creates Assertions and AssertionGroups.

Properties

descriptive

abstract val descriptive: Descriptive.HoldsOption

Builder to create a DescriptiveAssertion -- use it to create a simple assertion consisting of a DescriptiveAssertion.description (such as is less than) and a DescriptiveAssertion.representation (which most of time corresponds to the expected value).

explanatory

abstract val explanatory: Explanatory.ExplanationOption

Builder to create an ExplanatoryAssertion -- use it to explain something which is typically formatted by an ObjectFormatter -- has to be a child of an ExplanatoryGroup (see explanatoryGroup).

explanatoryGroup

abstract val explanatoryGroup: ExplanatoryAssertionGroupTypeOption

Builder to create an AssertionGroup with a ExplanatoryAssertionGroupType -- such a group is always shown in reporting (a Reporter has to neglect whether the Assertion.holds or not). Use it to provide explanations. It is inter alia used in Iterable contains entries assertions to describe the identification lambda you used.

feature

abstract val feature: DefaultAssertionGroupBuilderOptions<FeatureAssertionGroupType>

Builder to create an AssertionGroup with a FeatureAssertionGroupType -- use it if you want to make an Assertion about a feature of the subject.

list

abstract val list: DefaultAssertionGroupBuilderOptions<ListAssertionGroupType>

Builder to create an AssertionGroup with a ListAssertionGroupType -- kind of the default type for AssertionGroups, if you do not know what to choose, this is probably the best fit for you.

representationOnly

abstract val representationOnly: RepresentationOnly.HoldsStep

Builder to create an RepresentationOnlyAssertion -- typically used within an AssertionGroup where the description of the group gives enough context, so that this assertion does not require an additional description.

summary

abstract val summary: AssertionGroupDescriptionAndEmptyRepresentationOption<SummaryAssertionGroupType, AssertionsOption<SummaryAssertionGroupType, BasicAssertionGroupFinalStep>>

Builder to create an AssertionGroup with a SummaryAssertionGroupType -- use it if it is essential that also Assertions which hold are shown to a user in reporting. This kind is inter alia used for Iterable contains.inAnyOrder.only assertions where it quickly gets confusing if you do not see the assertions which hold.

Functions

createDescriptive

open fun createDescriptive(description: String, representation: Any?, test: () -> Boolean): DescriptiveAssertion
open fun createDescriptive(description: Translatable, representation: Any?, test: () -> Boolean): DescriptiveAssertion

Creates a DescriptiveAssertion based on the given description, representation and test.

customType

abstract fun <T : AssertionGroupType> customType(groupType: T): DefaultAssertionGroupBuilderOptions<T>

Builder to create a basic AssertionGroup with a custom AssertionGroupType.

Extension Properties

fixedClaimGroup

val AssertionBuilder.fixedClaimGroup: FixedClaimGroup.GroupTypeOption

Builder to create an AssertionGroup whose AssertionGroup.holds is fixed (not determined based on its AssertionGroup.assertions).

invisibleGroup

val AssertionBuilder.invisibleGroup: AssertionsOption<InvisibleAssertionGroupType, BasicAssertionGroupFinalStep>

Builder to create an AssertionGroup with an InvisibleAssertionGroupType -- use it only if you have several independent Assertions which should be evaluated together.

partiallyFixedClaimGroup

val AssertionBuilder.partiallyFixedClaimGroup: PartiallyFixedClaimGroup.GroupTypeOption

Builder to create an AssertionGroup whose AssertionGroup.holds is a logic AND operation composed by a fixed part and its AssertionGroup.assertions.

root

val AssertionBuilder.root: DefaultAssertionGroupBuilderOptions<RootAssertionGroupType>

Builder to create the root AssertionGroup -- do not use it in assertion functions; this group should only be created by RootExpects.