doc / ch.tutteli.atrium / IAtriumFactory

IAtriumFactory

interface IAtriumFactory

The minimum contract of the 'abstract factory' of atrium.

It is extended with the following extension functions defined in the atrium-api (in the same file as this interface):

It provides factory methods to create:

Functions

newCheckImmediately

open fun <T : Any> newCheckImmediately(assertionVerb: ITranslatable, subject: T, reporter: IReporter): IAssertionPlant<T>
open fun <T : Any> newCheckImmediately(assertionVerb: ITranslatable, subject: T, assertionChecker: IAssertionChecker): IAssertionPlant<T>
abstract fun <T : Any> newCheckImmediately(commonFields: CommonFields<T>): IAssertionPlant<T>

Creates an IAssertionPlant which immediately checks added IAssertions.

newCheckLazily

open fun <T : Any> newCheckLazily(assertionVerb: ITranslatable, subject: T, reporter: IReporter): IAssertionPlant<T>
open fun <T : Any> newCheckLazily(assertionVerb: ITranslatable, subject: T, assertionChecker: IAssertionChecker): IAssertionPlant<T>
abstract fun <T : Any> newCheckLazily(commonFields: CommonFields<T>): IAssertionPlant<T>

Creates an IAssertionPlant which does not check the created or added IAssertions until one calls IAssertionPlant.checkAssertions.

newDetailedObjectFormatter

abstract fun newDetailedObjectFormatter(translator: ITranslator): IObjectFormatter

Creates an IObjectFormatter which represents objects by using their Object.toString representation including Class.name and their System.identityHashCode.

newDownCastBuilder

abstract fun <TSub : T, T : Any> newDownCastBuilder(description: ITranslatable, subType: KClass<TSub>, commonFields: CommonFields<T?>): IDownCastBuilder<T, TSub>

n Use the extension function ch.tutteli.atrium.newDownCastBuilder with reified type parameter whenever possible.

newFeatureAssertionChecker

abstract fun <T : Any> newFeatureAssertionChecker(subjectPlant: IAssertionPlant<T>): IAssertionChecker

Creates an IAssertionChecker which creates IFeatureAssertionGroup instead of checking assertions and delegates this task to the given subjectPlant by adding (see IAssertionPlant.addAssertion the created IFeatureAssertionGroup to it.

newMethodCallFormatter

abstract fun newMethodCallFormatter(): IMethodCallFormatter

Creates an IMethodCallFormatter which represents arguments of a method call by using their Object.toString representation with the exception of:

newNullable

open fun <T> newNullable(assertionVerb: ITranslatable, subject: T, reporter: IReporter): IAssertionPlantNullable<T>
open fun <T> newNullable(assertionVerb: ITranslatable, subject: T, assertionChecker: IAssertionChecker): IAssertionPlantNullable<T>
abstract fun <T> newNullable(commonFields: CommonFields<T>): IAssertionPlantNullable<T>

Creates an IAssertionPlantNullable.

newOnlyFailureReporter

abstract fun newOnlyFailureReporter(assertionFormatter: IAssertionFormatter): IReporter

Creates an IReporter which reports only failing assertions and uses the given assertionFormatter to format assertions and messages.

newSameLineAssertionFormatter

abstract fun newSameLineAssertionFormatter(objectFormatter: IObjectFormatter, translator: ITranslator): IAssertionFormatter

Creates an IAssertionFormatter which puts messages of the form 'a: b' on the same line.

newThrowingAssertionChecker

abstract fun newThrowingAssertionChecker(reporter: IReporter): IAssertionChecker

Creates an IAssertionChecker which throws AssertionErrors in case an assertion fails and uses the given reporter for reporting.

newTranslator

abstract fun newTranslator(translationSupplier: ITranslationSupplier, primaryLocale: Locale, vararg fallbackLocales: Locale): ITranslator

Creates an ITranslator which translates ITranslatables to primaryLocale and falls back to fallbackLocales (in the given order) in case no translation exists for primaryLocale.

Extension Functions

newCheckLazilyAtTheEnd

fun <T : Any> IAtriumFactory.newCheckLazilyAtTheEnd(assertionVerb: ITranslatable, subject: T, reporter: IReporter, createAssertions: IAssertionPlant<T>.() -> Unit): IAssertionPlant<T>

Use this function to create a custom assertion verb which lazy evaluates assertions (see IAtriumFactory.newCheckLazily).

newDownCastBuilder

fun <TSub : T, T : Any> IAtriumFactory.newDownCastBuilder(description: ITranslatable, commonFields: CommonFields<T?>): IDownCastBuilder<T, TSub>

Prepares a down cast; use IDownCastBuilder.cast to perform the down cast.

Inheritors

AtriumFactory

object AtriumFactory : IAtriumFactory

A dummy implementation of IAtriumFactory which should be replaced by an actual implementation.