Add arbitrary ExpectBlock
s to this Expect
.
Add arbitrary ExpectBlock
s to this Expect
.
This is helpful to refactor code. For example: imagine you have an error case you want to add to multiple expects. You could leverage this method to do so in the following way:
def errorCaseExpectBlock(expect: Expect[String]): Unit { expect.expect .when("Some error") .returning("Got some error") } //Then in your expects def parseOutputA: Expect[String] = { val e = new Expect("some command", "") e.expect(...) e.expect .when(...) .action1 .when(...) .action2 e.addExpectBlock(errorCaseExpectBlock) } def parseOutputB: Expect[String] = { val e = new Expect("some command", "") e.expect .when(...) .action1 .action2 .when(...) .action1 e.expect(...) .action2 e.addExpectBlock(errorCaseExpectBlock) }
function that adds ExpectBlock
s.
this Expect
.
Adds, in a new ExpectBlock
, a EndOfFileWhen
that matches whenever the end of file is reached while trying to
read from the process output (stdOut).
Adds, in a new ExpectBlock
, a EndOfFileWhen
that matches whenever the end of file is reached while trying to
read from the process output (stdOut). This is a shortcut to expect.when(pattern)
.
the pattern to be used in the EndOfFileWhen
.
the new RegexWhen
.
Adds, in a new ExpectBlock
, a TimeoutWhen
that matches whenever the read from the process output (stdOut)
times out.
Adds, in a new ExpectBlock
, a TimeoutWhen
that matches whenever the read from the process output (stdOut)
times out. This is a shortcut to expect.when(pattern)
.
the pattern to be used in the TimeoutWhen
.
the new RegexWhen
.
Adds, in a new ExpectBlock
, a RegexWhen
that matches whenever the regex pattern
successfully matches
against the text read from the process output (stdOut).
Adds, in a new ExpectBlock
, a RegexWhen
that matches whenever the regex pattern
successfully matches
against the text read from the process output (stdOut). This is a shortcut to expect.when(pattern)
.
the pattern to be used in the RegexWhen
.
the new RegexWhen
.
Adds, in a new ExpectBlock
, a StringWhen
that matches whenever pattern
is contained
in the text read from the process output (stdOut).
Adds, in a new ExpectBlock
, a StringWhen
that matches whenever pattern
is contained
in the text read from the process output (stdOut). This is a shortcut to expect.when(pattern)
.
the pattern to be used in the StringWhen
.
the new StringWhen
.
Adds an empty new ExpectBlock
.
Adds an empty new ExpectBlock
.
the new ExpectBlock
.