Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactor Build, add Helpers (don't do anything yet)

  • Loading branch information...
commit 4a4c834b05c768cf9b207336e9363e16e918ebdb 1 parent 834e9e0
jtournay authored
View
19 build.sbt
@@ -1,19 +0,0 @@
-import sbt.Defaults._
-
-sbtPlugin := true
-
-name := "play-plugins-testng"
-
-version := "1.0-SNAPSHOT"
-
-organization := "com.linkedin"
-
-publishTo := Some(Resolver.file("Local repo", new File(Path.userHome.absolutePath + "/Documents/linkedin/play2/repository/local"))(Resolver.ivyStylePatterns))
-
-publishMavenStyle := false
-
-libraryDependencies <++= (scalaVersion, sbtVersion) {
- case (scalaVersion, sbtVersion) => Seq(
- sbtPluginExtra("de.johoop" % "sbt-testng-plugin" % "2.0.2", sbtVersion, scalaVersion)
- )
-}
View
20 src/main/scala/NGPlugin.scala → plugin/src/main/scala/NGPlugin.scala
@@ -27,3 +27,23 @@ object NGPlugin extends Plugin {
"de.johoop" %% "sbt-testng-interface" % "2.0.2" % "test"))
)
}
+
+import org.scalatools.testing.{Fingerprint, SubclassFingerprint, Framework, Logger, EventHandler}
+import java.util.concurrent.Semaphore
+import de.johoop.testnginterface._
+
+class WrappedTestNGFramework extends Framework {
+ val name = "TestNGFakeApp"
+
+ val tests = Array[Fingerprint](Annotated("com.linkedin.plugin.FakeApplication"))
+
+ def testRunner(testClassLoader: ClassLoader, loggers: Array[Logger]) = new WrappedTestNGRunner(testClassLoader, loggers, sharedState)
+
+ private[this] val sharedState = new TestRunState
+}
+
+class WrappedTestNGRunner(testClassLoader: ClassLoader, loggers: Array[Logger], state: TestRunState) extends TestNGRunner(testClassLoader: ClassLoader, loggers: Array[Logger], state: TestRunState) {
+ override def run(testClassname: String, fingerprint: Fingerprint, eventHandler: EventHandler, testOptions: Array[String]) = {
+ super.run(testClassname, fingerprint, eventHandler, testOptions)
+ }
+}
View
36 project/Build.scala
@@ -0,0 +1,36 @@
+import sbt._
+import sbt.Defaults._
+import sbt.Keys._
+
+object NGPluginBuild extends Build {
+
+ lazy val root = Project(
+ id = "play-testng-helpers",
+ base = file("."),
+ settings = Project.defaultSettings ++ commonSettings ++ Seq(
+ version := "1.0-SNAPSHOT",
+ crossScalaVersions := Seq("2.9.1"),
+ libraryDependencies ++= Seq()))
+
+ lazy val NGPlugin = Project(
+ id = "play-plugins-testng",
+ base = file("plugin"),
+ settings = Project.defaultSettings ++ commonSettings ++ Seq(
+ sbtPlugin := true,
+ version := "1.0-SNAPSHOT",
+ crossScalaVersions := Seq("2.9.1"),
+ libraryDependencies <++= (scalaVersion, sbtVersion) {
+ case (scalaVersion, sbtVersion) => Seq(
+ sbtPluginExtra("de.johoop" % "sbt-testng-plugin" % "2.0.2", sbtVersion, scalaVersion),
+ "de.johoop" %% "sbt-testng-interface" % "2.0.2"
+ )
+ }))
+
+ lazy val commonSettings: Seq[Setting[_]] = publishSettings ++ Seq(
+ organization := "com.linkedin",
+ scalaVersion := "2.9.1")
+
+ lazy val publishSettings: Seq[Setting[_]] = Seq(publishTo := Some(
+ Resolver.file("Local repo", new File(Path.userHome.absolutePath + "/Documents/linkedin/play2/repository/local"))(Resolver.ivyStylePatterns)),
+ publishMavenStyle := false)
+}
View
0  project/plugins.sbt
No changes.
View
1  sample/project/Build.scala
@@ -11,6 +11,7 @@ object ApplicationBuild extends Build {
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
+ "com.linkedin" %% "play-testng-helpers" % "1.0-SNAPSHOT"
)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
View
13 sample/test/SimpleTest.java
@@ -1,13 +1,24 @@
import org.testng.annotations.*;
+
+import play.mvc.*;
+import play.test.*;
+import play.libs.F.*;
+
+import static play.test.Helpers.*;
public class SimpleTest {
@Test
public void aFastTest() {
- System.out.println("Fast test");
+ running(fakeApplication(inMemoryDatabase()), new Runnable() {
+ public void run() {
+ System.out.println("Fast test");
+ }
+ });
}
@Test
+ @com.linkedin.plugin.FakeApplication
public void aFailingTest() {
if(true) throw new RuntimeException("FAIL");
System.out.println("failing test");
View
9 src/main/java/com/linkedin/plugin/FakeApplication.java
@@ -0,0 +1,9 @@
+package com.linkedin.plugin;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+@Target(ElementType.METHOD)
+public @interface FakeApplication {
+ String conf() default "";
+}
Please sign in to comment.
Something went wrong with that request. Please try again.