AsyncFeatureSpec: mapping multiple assertions to future

135 views
Skip to first unread message

rachna....@gmail.com

unread,
Dec 14, 2016, 7:11:26 PM12/14/16
to scalatest-users
Hi,
  How can I map multiple assertions to the future:

class TVSetActorSpec extends AsyncFeatureSpec with GivenWhenThen {

  implicit override def executionContext =
    scala.concurrent.ExecutionContext.Implicits.global

  info("As a TV set owner")
  info("I want to be able to turn the TV on and off")
  info("So I can watch TV when I want")
  info("And save energy when I'm not watching TV")

  feature("TV power button") {
    scenario("User presses power button when TV is off") {

      Given("a TV set that is switched off")
      val tvSetActor = new TVSetActor

      When("the power button is pressed")
      tvSetActor ! PressPowerButton

      Then("the TV should switch on")
      val futureBoolean = tvSetActor ? IsOn
      futureBoolean map { 
_ => myfunction()
} } scenario("User presses power button when TV is on") { Given("a TV set that is switched on") val tvSetActor = new TVSetActor tvSetActor ! PressPowerButton When("the power button is pressed") tvSetActor ! PressPowerButton Then("the TV should switch off") val futureBoolean = tvSetActor ? IsOn futureBoolean map {
_ => myfunction()
 } } } }

def myfunction() = {
assert(assertion1)
assert(assertion2)
assert(assertion3)

}


If assertion(1) fails will the future fail?

Thanks,
Rachna

Bill Venners

unread,
Dec 14, 2016, 7:12:13 PM12/14/16
to scalate...@googlegroups.com
Hi Rachna,

Yes, that will fail the future assertion, causing the test to fail.

Bill

--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalatest-users@googlegroups.com
To unsubscribe from this group, send email to
scalatest-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com
Reply all
Reply to author
Forward
0 new messages