GlanceNodeAssertionCollection

class GlanceNodeAssertionCollectionAny?, T : GlanceNode>

Represents a collection of Glance nodes from the tree that can be asserted on.

An instance of GlanceNodeAssertionCollection can be obtained from GlanceNodeAssertionsProvider.onAllNodes and equivalent methods.

Summary

Public functions

GlanceNodeAssertionCollection

Asserts that all the nodes in this collection satisfy the given matcher.

GlanceNodeAssertionCollection

Asserts that this collection contains at least one element that satisfies the given matcher.

GlanceNodeAssertionCollection
assertCountEquals(expectedCount: Int)

Asserts that this collection of nodes is equal to the given expectedCount.

GlanceNodeAssertionCollection

Returns a new collection of nodes by filtering the given nodes using the provided matcher.

operator GlanceNodeAssertion
get(index: Int)

Returns a GlanceNodeAssertion that can assert on the node at the given index of this collection.

Public functions

assertAll

Added in 1.1.0
fun assertAll(matcher: GlanceNodeMatcher): GlanceNodeAssertionCollection

Asserts that all the nodes in this collection satisfy the given matcher.

Doesn't throw error if the collection is empty. Use assertCountEquals to assert on expected size of the collection.

Parameters
matcher: GlanceNodeMatcher

Matcher that has to be satisfied by all the nodes in the collection.

Throws
kotlin.AssertionError

if the collection contains at least one element that does not satisfy the given matcher.

assertAny

Added in 1.1.0
fun assertAny(matcher: GlanceNodeMatcher): GlanceNodeAssertionCollection

Asserts that this collection contains at least one element that satisfies the given matcher.

Parameters
matcher: GlanceNodeMatcher

Matcher that has to be satisfied by at least one of the nodes in the collection.

Throws
kotlin.AssertionError

if not at least one matching node was found.

assertCountEquals

Added in 1.1.0
fun assertCountEquals(expectedCount: Int): GlanceNodeAssertionCollection

Asserts that this collection of nodes is equal to the given expectedCount.

Throws
kotlin.AssertionError

if the size is not equal to expectedCount

filter

Added in 1.1.0
fun filter(matcher: GlanceNodeMatcher): GlanceNodeAssertionCollection

Returns a new collection of nodes by filtering the given nodes using the provided matcher.

get

Added in 1.1.0
operator fun get(index: Int): GlanceNodeAssertion

Returns a GlanceNodeAssertion that can assert on the node at the given index of this collection.

Any subsequent assertion on its result will throw error if index is out of bounds of the matching nodes found from previous operations.