GlanceNodeAssertion
class GlanceNodeAssertion<R : Any?, T : GlanceNode<R>>
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<R, T> |
assert(matcher: GlanceNodeMatcher<R>, messagePrefixOnError: (() -> String)?)Asserts that the provided |
GlanceNodeAssertion<R, T> |
Asserts that no matching node was found. |
GlanceNodeAssertion<R, T> |
Asserts that the node was found. |
GlanceNodeAssertionCollection<R, T> |
Returns |
Public functions
assert
fun assert(
matcher: GlanceNodeMatcher<R>,
messagePrefixOnError: (() -> String)? = null
): GlanceNodeAssertion<R, T>
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<R> |
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
fun assertDoesNotExist(): GlanceNodeAssertion<R, T>
Asserts that no matching node was found.
| Throws | |
|---|---|
kotlin.AssertionError |
if the assert fails. |
assertExists
fun assertExists(): GlanceNodeAssertion<R, T>
Asserts that the node was found.
| Throws | |
|---|---|
kotlin.AssertionError |
if the assert fails. |
onChildren
fun onChildren(): GlanceNodeAssertionCollection<R, T>
Returns GlanceNodeAssertionCollection that allows performing assertions on the children of the node selected by this GlanceNodeAssertion.