playframework - How can I use TestNG with Java Play 2.4.x? -
i use testng in java play project instead of junit testing (it has more robust features). however, there doesn't appear documentation on how since play seems treat java second class citizen compared scala. know how configure java play project use testng?
- add following dependencies build.sbt:
librarydependencies ++= seq( ... "org.testng" % "testng" % "6.8.8", "de.johoop" % "sbt-testng-interface_2.10" % "3.0.0", "org.scalatest" %% "scalatest" % "2.2.1", "org.scalatestplus" %% "play" % "1.4.0-m4" )
add following dependencies plugins.sbt (in "project [root-build]"):
addsbtplugin("de.johoop" % "sbt-testng-plugin" % "3.0.2")
restructure "test" directory classes part of package structure. example:
test --- com.test.integration ------ integrationtest.java --- com.test.unit ------ unittest.java
add new test file (ex: exampleintegrationtest.java) 1 of test packages ("unit" or "integration") basic test. should extend "testngsuite" class (part of scalatest module).
public class exampleintegrationtest extends testngsuite { @test public void test() { assert.asserttrue(true); } }
in terminal / console, navigate project directory , run following command:
activator clean compile
once has compiled, run:
activator test
if goes well, should see 1 successful test executed.
Comments
Post a Comment