0

Is there a way to run a function before the tests get started?
For example:

object KkConsumerSpec extends Properties("Consumer")  {

  //Some preparation work here!!!!   

  property("startsWith") = forAll { (a: String, b: String) =>
    (a+b).startsWith(a)
  }

}

I want to run some functions before the test startsWith starts.

softshipper
  • 32,463
  • 51
  • 192
  • 400
  • Could you please describe in more details what you want to achieve? Typically in unit tests you use such code to create some fixtures but in ScalaCheck you control how new objects to check properties are created using generators (`Gen[T]`) and from generator implementation you can call arbitrary code (including access to some `lazy val`). So why do you want this? – SergGr Dec 04 '17 at 13:44
  • Before each is getting started, for example create a file that test scenario needs. – softshipper Dec 05 '17 at 07:13

1 Answers1

0

If I understand what you want to do, all you have to do is extend BeforeAndAfterAll and then override one of the beforeAll methods.

rleibman
  • 147
  • 7