Skip to content

Instantly share code, notes, and snippets.

@vsimko
Created October 7, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsimko/e988ffc3f5910cd46d86bfd69bcc67d7 to your computer and use it in GitHub Desktop.
Save vsimko/e988ffc3f5910cd46d86bfd69bcc67d7 to your computer and use it in GitHub Desktop.
example of a test in scala
// 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