GlanceNodeAssertion

class GlanceNodeAssertionAny?, T : GlanceNode>

Represents a Glance node from the tree that can be asserted on.

An instance of GlanceNodeAssertion can be obtained from onNode and equivalent methods on a GlanceNodeAssertionsProvider

Summary

Public functions

GlanceNodeAssertion
assert(matcher: GlanceNodeMatcher, messagePrefixOnError: (() -> String)?)

Asserts that the provided matcher is satisfied for this node.

GlanceNodeAssertion

Asserts that no matching node was found.

GlanceNodeAssertion

Asserts that the node was found.

GlanceNodeAssertionCollection

Returns GlanceNodeAssertionCollection that allows performing assertions on the children of the node selected by this GlanceNodeAssertion.

Public functions

assert

Added in 1.1.0
fun assert(
    matcher: GlanceNodeMatcher,
    messagePrefixOnError: (() -> String)? = null
): GlanceNodeAssertion

Asserts that the provided matcher is satisfied for this node.

This function also can be used to create convenience "assert{somethingConcrete}" methods as extension functions on the GlanceNodeAssertion.

Parameters
matcher: GlanceNodeMatcher

Matcher to verify.

messagePrefixOnError: (() -> String)? = null

Prefix to be put in front of an error that gets thrown in case this assert fails. This can be helpful in situations where this assert fails as part of a bigger operation that used this assert as a precondition check.

Throws
kotlin.AssertionError

if the matcher does not match or the node can no longer be found.

assertDoesNotExist

Added in 1.1.0
fun assertDoesNotExist(): GlanceNodeAssertion

Asserts that no matching node was found.

Throws
kotlin.AssertionError

if the assert fails.

assertExists

Added in 1.1.0
fun assertExists(): GlanceNodeAssertion

Asserts that the node was found.

Throws
kotlin.AssertionError

if the assert fails.

onChildren

Added in 1.1.0
fun onChildren(): GlanceNodeAssertionCollection

Returns GlanceNodeAssertionCollection that allows performing assertions on the children of the node selected by this GlanceNodeAssertion.