scala - How to make JUnit4 lifecycle callbacks work in ScalaTest with JUnitRunner? -


according scalatest documentation it's possible use junitrunner run tests. assumption was, if runs junitrunner, callback methods (i.e. methods marked @before or @after annotation should work well. apparently assumption wrong. i've created simple example demonstrate it:

import org.junit.before import org.junit.runner.runwith import org.scalatest.{funsuite, _} import org.scalatest.junit.junitrunner  @runwith(classof[junitrunner]) class test extends funsuite {    @before   def before() = {     println("before test")   }    test("nothing") {     println("test started")   } } 

if run example, you'll see test started line, not before test.

i'm aware of scalatest lifecycle callbacks, thing need make junit callbacks work somehow. want write test play 2.4 application , thing it's play.test.withbrowser class relies on junit callbacks. found workaround issue:

 var testbrowser : testbrowser = _   before {    new withbrowser {      override def createbrowser(): unit = {        super.createbrowser()        testbrowser = browser      }  }.createbrowser() 

}

but believe it's quite ugly , suspect there better way.

so, question if it's possible make these junit lifecycle callbacks work scalatest? , if possible, how that?

you should able using junitsuite instead of funsuite. documentation here:

http://www.scalatest.org/getting_started_with_junit_4_in_scala http://doc.scalatest.org/2.2.4/index.html#org.scalatest.junit.junitsuite


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -