Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to @Before or beforeEach in Scalatest

Tags:

scalatest

Test frameworks like jasmine and junit provide ways to configure the test environment before each test is run. Is something similar available in scalatest and playspec?

like image 799
Manu Chadha Avatar asked Oct 23 '25 15:10

Manu Chadha


1 Answers

In scalatest you can use traits BeforeAndAfterAll and BeforeAndAfterEach to add such methods, then you need to override them fe:

class BaseTest extends FlatSpec with BeforeAndAfterAll with BeforeAndAfterEach{

  override def beforeAll(): Unit = {
    super.beforeAll()
    //your logic here
  }

  //..

}
like image 76
Mateusz Gruszczynski Avatar answered Oct 26 '25 08:10

Mateusz Gruszczynski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!