Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

JUnit + TestNG in the same folder, runned with test:test

  • Loading branch information...
commit 46b41295515c91f60aa57743363ff8bcea0cb88f 1 parent 2205e40
jtournay authored
5 sample/project/Build.scala
View
@@ -2,6 +2,9 @@ import sbt._
import Keys._
import PlayProject._
+import com.linkedin.plugin.NGPlugin
+import com.linkedin.plugin.NGPlugin._
+
object ApplicationBuild extends Build {
val appName = "Sample"
@@ -13,5 +16,7 @@ object ApplicationBuild extends Build {
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
// Add your own project settings here
)
+ //.configs(NGTest)
+ //.settings(NGPlugin.ngSettings: _*)
}
17 sample/test/JUnitTest.java
View
@@ -0,0 +1,17 @@
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class JUnitTest {
+
+ @Test
+ public void aFastTest() {
+ System.out.println("Fast test");
+ }
+
+ @Test
+ public void aFailingTest() {
+ assertTrue(false);
+ System.out.println("failing test");
+ }
+
+}
5 sample/test/SimpleTest.java
View
@@ -8,8 +8,9 @@ public void aFastTest() {
}
@Test
- public void aSlowTest() {
- System.out.println("Slow test");
+ public void aFailingTest() {
+ if(true) throw new RuntimeException("FAIL");
+ System.out.println("failing test");
}
}
30 src/main/scala/NGPlugin.scala
View
@@ -7,19 +7,23 @@ import de.johoop.testngplugin.TestNGPlugin._
object NGPlugin extends Plugin {
- val PREFIX = "ng"
+ override def settings: Seq[Setting[_]] = ngSettings
- override def settings: Seq[Setting[_]] = super.settings ++ Seq(
- scalaSource in Test <<= baseDirectory / "junit",
- javaSource in Test <<= baseDirectory / "junit",
- testListeners in Test := Seq()
- ) ++ inConfig(NGTest)(Defaults.testSettings ++ testNGSettings) ++ Seq(
- scalaSource in NGTest <<= baseDirectory / "test",
- javaSource in NGTest <<= baseDirectory / "test",
- libraryDependencies <++= (testNGVersion in NGTest)(v => Seq(
- "org.testng" % "testng" % v,
- "de.johoop" %% "sbt-testng-interface" % "2.0.2"))
+ def ngSettings: Seq[Setting[_]] = super.settings ++ Seq(
+ testOptions in Test := Seq(),
+ testOptions in Test += Tests.Setup { loader =>
+ loader.loadClass("play.api.Logger").getMethod("init", classOf[java.io.File]).invoke(null, new java.io.File("."))
+ },
+ testOptions in Test += Tests.Cleanup { loader =>
+ loader.loadClass("play.api.Logger").getMethod("shutdown").invoke(null)
+ },
+ //testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "sequential", "true"),
+ testOptions in Test += Tests.Argument(TestFrameworks.JUnit,"junitxml", "console")
+ ) ++
+ inConfig(Test)(testNGSettings) ++
+ Seq(
+ libraryDependencies <++= (testNGVersion in Test)(v => Seq(
+ "org.testng" % "testng" % v % "test->default",
+ "de.johoop" %% "sbt-testng-interface" % "2.0.2" % "test"))
)
-
- lazy val NGTest = config(PREFIX) extend(Test)
}
Please sign in to comment.
Something went wrong with that request. Please try again.