Permalink
Browse files

Run Reactive Streams tests with ScalaTest

The motivation for using sbt-testng-interface originally was to be
independent of Scala versions with a pure Java solution but this
back-fired because the actual interface implementation of
sbt-testng-interface is actually written in Scala. In order to build on
Scala 2.12 milestones, we are switching to ScalaTest for running the
TestNG tests. It has the same binary compatibility issues in theory but
there are builds available for Scala 2.12 milestone releases.
  • Loading branch information...
1 parent 20aed4c commit ef65d0b2d0c81dbf64390a3933f8e93cd5008a8c @szeiger szeiger committed Sep 29, 2015
View
@@ -4,6 +4,7 @@ target/
/test-dbs/*_*
/test-dbs/databases.properties
/test-dbs/testkit.conf
+/test-output/
*.log
*.iml
*.pyc
View
@@ -9,24 +9,24 @@ import com.typesafe.tools.mima.plugin.MimaKeys.{previousArtifact, binaryIssueFil
import com.typesafe.tools.mima.core.{ProblemFilters, MissingClassProblem}
import com.typesafe.sbt.osgi.SbtOsgi.{osgiSettings, OsgiKeys}
import com.typesafe.sbt.sdlc.Plugin._
-import de.johoop.testngplugin.TestNGPlugin._
object SlickBuild extends Build {
val slickVersion = "3.2.0-SNAPSHOT"
val slickExtensionsVersion = slickVersion // Slick extensions version for links in the manual
val binaryCompatSlickVersion = "3.2.0" // Slick base version for binary compatibility checks
- val scalaVersions = Seq("2.11.7")
+ val scalaVersions = Seq("2.11.7", "2.12.0-M2")
/** Dependencies for reuse in different parts of the build */
object Dependencies {
val junit = Seq(
"junit" % "junit-dep" % "4.10",
"com.novocode" % "junit-interface" % "0.11"
)
- val testngExtras = Seq(
- "com.google.inject" % "guice" % "2.0"
- )
+ def scalaTestFor(scalaVersion: String) = {
+ val v = if(scalaVersion == "2.12.0-M2") "2.2.5-M2" else "2.2.4"
+ "org.scalatest" %% "scalatest" % v
+ }
val slf4j = "org.slf4j" % "slf4j-api" % "1.7.10"
val logback = "ch.qos.logback" % "logback-classic" % "1.1.3"
val typesafeConfig = "com.typesafe" % "config" % "1.2.1"
@@ -311,15 +311,14 @@ object SlickBuild extends Build {
) dependsOn(slickProject)
lazy val reactiveStreamsTestProject = Project(id = "reactive-streams-tests", base = file("reactive-streams-tests"),
- settings = Defaults.coreDefaultSettings ++ sharedSettings ++ testNGSettings ++ Seq(
+ settings = Defaults.coreDefaultSettings ++ sharedSettings ++ Seq(
name := "Slick-ReactiveStreamsTests",
unmanagedResourceDirectories in Test += (baseDirectory in aRootProject).value / "common-test-resources",
resolvers += Resolver.sbtPluginRepo("releases"),
- libraryDependencies ++=
- (Dependencies.logback +: Dependencies.testDBs).map(_ % "test") ++:
- Dependencies.reactiveStreamsTCK +:
- Dependencies.testngExtras,
- testNGSuites := Seq("reactive-streams-tests/src/test/resources/testng.xml")
+ libraryDependencies += Dependencies.scalaTestFor(scalaVersion.value),
+ libraryDependencies ++= (Dependencies.logback +: Dependencies.testDBs).map(_ % "test"),
+ libraryDependencies += Dependencies.reactiveStreamsTCK,
+ parallelExecution in Test := false
)
) dependsOn(slickTestkitProject)
@@ -1,14 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-
-<suite name="ReactiveStreams" verbose="0" >
- <test name="ReactiveStreams">
- <classes>
- <class name="slick.test.stream.JdbcPublisherTest"/>
- <class name="slick.test.stream.HeapPublisherTest"/>
- </classes>
- </test>
-
- <listeners>
- <listener class-name="slick.test.stream.TestNGConsoleListener" />
- </listeners>
-</suite>
@@ -5,14 +5,15 @@ import java.util.concurrent.atomic.AtomicInteger
import org.reactivestreams._
import org.reactivestreams.tck._
import org.testng.annotations.{AfterClass, BeforeClass}
+import org.scalatest.testng.TestNGSuiteLike
import slick.profile.RelationalProfile
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.util.control.NonFatal
-abstract class RelationalPublisherTest[P <: RelationalProfile](val driver: P, timeout: Long) extends PublisherVerification[Int](new TestEnvironment(timeout), 1000L) {
+abstract class RelationalPublisherTest[P <: RelationalProfile](val driver: P, timeout: Long) extends PublisherVerification[Int](new TestEnvironment(timeout), 1000L) with TestNGSuiteLike {
import driver.api._
override def maxElementsFromPublisher = 73L
@@ -1,38 +0,0 @@
-package slick.test.stream
-
-import org.testng.{ITestResult, TestListenerAdapter}
-
-import slick.util.GlobalConfig
-
-class TestNGConsoleListener extends TestListenerAdapter {
- val (normal, yellow, blue, cyan, red) =
- if(GlobalConfig.ansiDump) ("\u001B[0m", "\u001B[33m", "\u001B[34m", "\u001B[36m", "\u001B[31m")
- else ("", "", "", "", "")
-
- override def onTestFailure(tr: ITestResult): Unit = {
- printError(tr, tr.getThrowable, "failed", red)
- }
-
- override def onTestSuccess(tr: ITestResult): Unit = {
- printError(tr, null, "succeeded", cyan)
- }
-
- override def onTestSkipped(tr: ITestResult): Unit = {
- printError(tr, null, "skipped", blue)
- }
-
- def printError(tr: ITestResult, t: Throwable, msg: String, highlight: String): Unit = {
- val cln = tr.getTestClass.getName
- val sep = cln.lastIndexOf('.')
- val cln2 = if(sep == -1) (yellow + cln) else cln.substring(0, sep+1) + yellow + cln.substring(sep+1)
- val mn = tr.getMethod.getMethodName
- val param = tr.getParameters.map(_.toString).mkString(",")
- val param2 = if(param == "") "" else s"[$yellow$param$normal]"
- print(s"Test $cln2$normal.$highlight$mn$normal$param2 $msg")
- if(t eq null) println()
- else {
- print(": ")
- t.printStackTrace(System.out)
- }
- }
-}

0 comments on commit ef65d0b

Please sign in to comment.