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
.
Add an arbitrary When
to this ExpectBlock
.
Add an arbitrary When
to this ExpectBlock
.
This is helpful to refactor code. For example: imagine you have an error case you want to add to
multiple ExpectBlock
s. You could leverage this method to do so in the following way:
def errorCaseWhen(expectBlock: ExpectBlock[String]): When[String] = { expectBlock .when("Some error") .returning("Got some error") } def parseOutputA: Expect[String] = { val e = new Expect("some command", "") e.expect .when(...) .sendln(...) e.expect .addWhen(errorCaseWhen) .exit() } def parseOutputB: Expect[String] = { val e = new Expect("some command", "") e.expect .when(...) .sendln(..) .returning(...) .addWhen(errorCaseWhen) }
This function returns the added When which allows you to add further actions, see the exit action of the
parseOutputA
method in the above code.
It is possible to add more than one When using this method, however this is discouraged since it will make the code somewhat more illegible because "hidden" Whens will also be added.
If you need to add more than one When you have two options:
e.expect .when(...) .sendln(..) .returning(...) .addWhen(errorCaseWhen) .addWhen(anotherWhen)
e.expect .when(...) .sendln(..) .returning(...) .addWhens(multipleWhens)
function that adds the When
.
the added When
.
Add arbitrary When
s to this ExpectBlock
.
Add arbitrary When
s to this ExpectBlock
.
This method is very similar to the addWhen
with the following differences:
f
has a more relaxed type.function that adds When
s.
this 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
.
Adds an empty new ExpectBlock
.
*
*
the core.ExpectBlock equivalent of this fluent.ExpectBlock.
Adds a new TimeoutWhen
that matches whenever a Timeout in thrown while trying to read text
from the process output (stdOut).
Adds a new TimeoutWhen
that matches whenever a Timeout in thrown while trying to read text
from the process output (stdOut).
the pattern to match against.
the new TimeoutWhen
.
Adds a new EndOfFileWhen
that matches whenever the EndOfFile in the process output (stdOut) is reached.
Adds a new EndOfFileWhen
that matches whenever the EndOfFile in the process output (stdOut) is reached.
the pattern to match against.
the new EndOfFileWhen
.
Adds a new RegexWhen
that matches whenever the regex pattern
successfully matches
against the text read from the process output (stdOut).
Adds a new RegexWhen
that matches whenever the regex pattern
successfully matches
against the text read from the process output (stdOut).
the pattern to match against.
the new RegexWhen
.
Adds a new StringWhen
that matches whenever pattern
is contained
in the text read from the process output (stdOut).
Adds a new StringWhen
that matches whenever pattern
is contained
in the text read from the process output (stdOut).
the pattern to match against.
the new StringWhen
.