|
|
Re: ScalaTest not executing before all
|
Posted: Oct 27, 2015 10:51 AM
|
|
> Hi All, > I have a scala test which extends flatspec style with > BeforeAndAfterAll. > > My problem is it's not running beforeall with shared tests > in behavior functions style.For example: > class TestBeforeAll extends FlatSpec with > BeforeAndAfterAll{ > > var abc :String = "bla" > > def printWord(word :String): Unit = > { > println("The word is :"+word) > } > override def beforeAll() = > { > print("In before all") > abc = "Hello" > } > > "A Stack" should behave like printWord(abc) > > } > Hi Lisa,
beforeAll will happen before tests, but you didn't register a test in the printWord(abc) method, just did a println. You need to do something like:
def printWord(word :String): Unit = { "A widget" should ("print this word: " + word) in { println("The word is :"+word) } }
|
|