XmlMatcher

case class XmlMatcher(functions: Seq[PathFunction]) extends Matcher[Seq[Node]]

The XmlMatcher class matches an xml Node, or a list of Nodes against a list of search functions, which can either search for:

  • a given direct child, with its label and/or attributes and/or attributes names and values

  • a given child, direct or not (maybe deeply nested), with its label and/or attributes and/or attributes names and values

XmlMatchers can be "chained" by using the \ or the \ methods. In that case, the resulting matcher has a new search function which tries to match the result of the preceding function. For example

 
must \\("c").\("d")

will be ok.

must \("c").("d")

trait Serializable
trait Product
trait Equals
trait Matcher[Seq[Node]]
class Object
trait Matchable
class Any

Value members

Concrete methods

def \(node: Node, attributeNames: String*): XmlMatcher
def \(node: Node, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher
def \(label: String, attributeNames: String*): XmlMatcher

alias for \ using the node label only

alias for \ using the node label only

def \(label: String, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher
def \>(t: String): XmlMatcher

alias for textIs

alias for textIs

def \>~[T](t: T)(using evidence$2: MatchingExpression[T]): XmlMatcher

alias for textMatches

alias for textMatches

def \\(node: Node, attributeNames: String*): XmlMatcher
def \\(node: Node, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher
def \\(label: String, attributeNames: String*): XmlMatcher

alias for \ using the node label only

alias for \ using the node label only

def \\(label: String, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher
def apply[S <: Seq[Node]](n: Expectable[S]): Result

checks that the nodes satisfy the functions

checks that the nodes satisfy the functions

def checkFunctions(pathFunctions: Seq[PathFunction], nodes: Seq[Node], messages: (Boolean, String, String)): (Boolean, String, String)

checks that the nodes satisfy the functions

checks that the nodes satisfy the functions

Returns:

a MatcherResult

do an exact match on attributes and attributes values

do an exact match on attributes and attributes values

def textIs(t: String): XmlMatcher

specify the value of the node text

specify the value of the node text

def textMatches[T](t: T)(using evidence$1: MatchingExpression[T]): XmlMatcher

specify the value of the node text

specify the value of the node text

Inherited methods

def ^^[S](f: S => Expectable[Seq[Node]], dummy: Int): Matcher[S]

Adapt a matcher to another. ex: be_==("message") ^^ (_.getMessage aka "trimmed") can be applied to an exception

Adapt a matcher to another. ex: be_==("message") ^^ (_.getMessage aka "trimmed") can be applied to an exception

The dummy value is used to help to disambiguate with the overloaded ^^ function

Inherited from:
Matcher
def ^^[S](f: S => Seq[Node]): Matcher[S]

Adapt a matcher to another. ex: be_==("message") ^^ (_.getMessage) can be applied to an exception

Adapt a matcher to another. ex: be_==("message") ^^ (_.getMessage) can be applied to an exception

Inherited from:
Matcher
infix def and[S <: Seq[Node]](m: => Matcher[S]): Matcher[S]

the logical and between 2 matchers

the logical and between 2 matchers

See also:

Result.and

Inherited from:
Matcher
def eventually(retries: Int, sleep: Int => Duration): Matcher[Seq[Node]]
Value parameters:
sleep

the function applied on the retry number (first is 1)

Returns:

a matcher that needs to eventually match, after a given number of retries and a sleep time

(aResult === expected).eventually(retries = 2, _ * 100.milliseconds)
Inherited from:
Matcher
def eventually(retries: Int, sleep: Duration): Matcher[Seq[Node]]
Returns:

a matcher that needs to eventually match, after a given number of retries and a sleep time

Inherited from:
Matcher
def eventually: Matcher[Seq[Node]]
Returns:

a matcher that needs to eventually match, after 40 retries and a sleep time of 100 milliseconds

Inherited from:
Matcher
def iff(b: Boolean): Matcher[Seq[Node]]

when the condition is true the matcher is applied, when it's false, the matcher must fail

when the condition is true the matcher is applied, when it's false, the matcher must fail

Inherited from:
Matcher
def lazily: Matcher[() => Seq[Node]]

The lazily operator returns a Matcher which will match a function returning the expected value

The lazily operator returns a Matcher which will match a function returning the expected value

Inherited from:
Matcher
def mute: Matcher[Seq[Node]]
Returns:

a Matcher with no messages

Inherited from:
Matcher
def not: Matcher[Seq[Node]]

negate a Matcher

negate a Matcher

See also:

Result.not

Inherited from:
Matcher
infix def or[S <: Seq[Node]](m: => Matcher[S]): Matcher[S]

the logical or between 2 matchers

the logical or between 2 matchers

See also:

Result.or

Inherited from:
Matcher
def orPending(message: String => String): Matcher[Seq[Node]]
Returns:

a Pending Result if this matcher fails, modifying the failure message with a pending message.

Inherited from:
Matcher
def orPending(m: String): Matcher[Seq[Node]]
Returns:

a Pending Result if this matcher fails, prefixing the failure message with a pending message. If the pending message is empty, only the failure message is printed

Inherited from:
Matcher
def orPending: Matcher[Seq[Node]]
Returns:

a Pending Result if this matcher fails

Inherited from:
Matcher
def orSkip(message: String => String): Matcher[Seq[Node]]
Returns:

a Skipped Result if this matcher fails, modifying the failure message with a skip message.

Inherited from:
Matcher
def orSkip(m: String): Matcher[Seq[Node]]
Returns:

a Skipped Result if this matcher fails, prefixing the failure message with a skip message. If the skip message is empty, only the failure message is printed

Inherited from:
Matcher
def orSkip: Matcher[Seq[Node]]
Returns:

a Skipped result if this matcher fails

Inherited from:
Matcher
def orThrow(message: String => String): Matcher[Seq[Node]]

throw a FailureException if this matcher fails, modifying the failure message with a message.

throw a FailureException if this matcher fails, modifying the failure message with a message.

Inherited from:
Matcher
def orThrow(m: String): Matcher[Seq[Node]]

throw a FailureException if this matcher fails prefixing the failure message with a message. If the message is empty, only the failure message is printed

throw a FailureException if this matcher fails prefixing the failure message with a message. If the message is empty, only the failure message is printed

Inherited from:
Matcher
def orThrow: Matcher[Seq[Node]]

throw a FailureException if this matcher fails

throw a FailureException if this matcher fails

Inherited from:
Matcher
def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product
def setMessage(message: String): Matcher[Seq[Node]]
Returns:

set a new failure message of a matcher

Inherited from:
Matcher
def test: Seq[Node] => Boolean
Returns:

a test function corresponding to this matcher

Inherited from:
Matcher
def unless(b: Boolean, m: String): Matcher[Seq[Node]]

only apply this matcher if the condition is false

only apply this matcher if the condition is false

Inherited from:
Matcher
def updateMessage(f: String => String): Matcher[Seq[Node]]
Returns:

update the failure message of a matcher

Inherited from:
Matcher
def when(b: Boolean, m: String): Matcher[Seq[Node]]

only apply this matcher if the condition is true

only apply this matcher if the condition is true

Inherited from:
Matcher