Created
October 7, 2016 12:34
-
-
Save vsimko/e988ffc3f5910cd46d86bfd69bcc67d7 to your computer and use it in GitHub Desktop.
example of a test in scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// taken from: http://www.scalatest.org/user_guide/selecting_a_style | |
class TVSetSpec extends FeatureSpec with GivenWhenThen { | |
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 tv = new TVSet | |
assert(!tv.isOn) | |
When("the power button is pressed") | |
tv.pressPowerButton() | |
Then("the TV should switch on") | |
assert(tv.isOn) | |
} | |
scenario("User presses power button when TV is on") { | |
Given("a TV set that is switched on") | |
val tv = new TVSet | |
tv.pressPowerButton() | |
assert(tv.isOn) | |
When("the power button is pressed") | |
tv.pressPowerButton() | |
Then("the TV should switch off") | |
assert(!tv.isOn) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment