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

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

Notice, if you want to use text (e.g. a String) as representation, then wrap it into a RawString via RawString.create and pass the RawString instead.

Shortcut for:

descriptive
  .withTest(test)
  .withDescriptionAndRepresentation(description, representation)
  .build()

Parameters

description - The description of the assertion, e.g. to Be

representation - The representation of the expected outcome

test - The test which checks whether the assertion holds

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

Creates a DescriptiveAssertion based on the description, representation and test as well as the SubjectProvider.maybeSubject of the given subjectProvider.

Notice, if you want to use text (e.g. a String) as representation, then wrap it into a RawString via RawString.create and pass the RawString instead.

Shortcut for:

descriptive
  .withTest(subjectProvider, test)
  .withDescriptionAndRepresentation(description, representation)
  .build()

Parameters

subjectProvider - The Expect from which we take the Expect.maybeSubject and pass it on to the given test.

description - The description of the assertion, e.g. to Be.

representation - The representation of the expected outcome.

test - The test which checks whether the assertion holds.

Exceptions

ch.tutteli.atrium.creating.PlantHasNoSubjectException - in case test is called in a context where it is not safe to call it. For instance, if test is called within an explanatory assertion where it is possible that AssertionPlant.maybeSubject is None.