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 an empty new ExpectBlock
.
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
.
Runs this Expect.
Runs this Expect.
the maximum time to wait for each read.
the charset to use when decoding/encoding the read/write text.
the size of the buffer to use when performing reads.
whether to redirect the stdErr of the spawned process to the stdOut.
the ExecutionContext upon which this Expect will be run.
a Future with the value returned by a ReturningAction
, if no ReturningAction
exists
defaultValue
will be returned. If an exception occurred during the execution of the future
then that exception will be returned in the Failure of the Future.
the core.Expect equivalent of this fluent.Expect.