Provide information and optionally, a payload, to the Reporter via an
InfoProvided event.
Provide information and optionally, a payload, to the Reporter via an
InfoProvided event.
a string that will be forwarded to the wrapped Reporter
via an InfoProvided event.
an optional object which will be forwarded to the wrapped Reporter
as a payload via an InfoProvided event.
if message or payload reference is null
Trait to which custom information about a running suite of tests can be reported.
An
Informeris essentially used to wrap aReporterand provide easy ways to send custom information to thatReportervia anInfoProvidedevent.Informercontains anapplymethod that takes a string and an optional payload object of typeAny. TheInformerwill forward the passedmessagestring to theReporteras themessageparameter, and the optional payload object as thepayloadparameter, of anInfoProvidedevent.Here's an example of using an
Informer:If you run this
Suitefrom the interpreter, you will see the message included in the printed report:scala> (new ExampleSuite).execute() ExampleSuite: - testAddition(Reporter) + Addition seems to workTraits
FunSuite,FunSpec,FlatSpec,WordSpec,FeatureSpec, and their sister traits inorg.scalatest.fixturepackage declare an implicitinfomethod that returns anInformer. This implicitinfois used, for example, to enable the syntax offered by theGivenWhenThentrait, which contains methods that take an implicitInformer. Here's an example of aFeatureSpecthat mixes inGivenWhenThen:Were you to run this
FeatureSpecin the interpreter, you would see the following messages included in the printed report:scala> (new ArithmeticFeatureSpec).run() Feature: Integer arithmetic Scenario: addition Given two integers When they are added Then the result is the sum of the two numbers Scenario: subtraction Given two integers When one is subtracted from the other Then the result is the difference of the two numbers