Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
specsy/specsy-examples/src/test/scala/org/specsy/examples/scala/ShareSideEffectsExampleSpec.scala
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (25 sloc)
773 Bytes
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
// Copyright © 2010-2016, Esko Luontola <www.orfjackal.net> | |
// This software is released under the Apache License 2.0. | |
// The license text is at http://www.apache.org/licenses/LICENSE-2.0 | |
package org.specsy.examples.scala | |
import org.specsy.scala.ScalaSpecsy | |
import org.hamcrest.MatcherAssert.assertThat | |
import org.hamcrest.Matchers._ | |
class ShareSideEffectsExampleSpec extends ScalaSpecsy { | |
var counter = 0 | |
// Without the call to `shareSideEffects()` the value of `counter` would be `1` | |
// in the asserts of each of the following child specs. | |
shareSideEffects() | |
"One" >> { | |
counter += 1 | |
assertThat(counter, is(1)) | |
} | |
"Two" >> { | |
counter += 1 | |
assertThat(counter, is(2)) | |
} | |
"Three" >> { | |
counter += 1 | |
assertThat(counter, is(3)) | |
} | |
} |