summaryrefslogtreecommitdiff
path: root/scalalib/test/src
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-04-08 12:55:30 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2018-04-08 12:55:30 -0700
commit62a18754179d74252668879c42e1c5d6a45fbdce (patch)
tree99a820224293a2367c116272283fd2a3426957ae /scalalib/test/src
parentdbcad35c05f1726f26b8033524e8fdd3d68b2de9 (diff)
downloadmill-62a18754179d74252668879c42e1c5d6a45fbdce.tar.gz
mill-62a18754179d74252668879c42e1c5d6a45fbdce.tar.bz2
mill-62a18754179d74252668879c42e1c5d6a45fbdce.zip
Enable JUnit testing, via sbt-test-interface, for `JavaModule`s
Diffstat (limited to 'scalalib/test/src')
-rw-r--r--scalalib/test/src/mill/scalalib/HelloJavaTests.scala43
1 files changed, 37 insertions, 6 deletions
diff --git a/scalalib/test/src/mill/scalalib/HelloJavaTests.scala b/scalalib/test/src/mill/scalalib/HelloJavaTests.scala
index 7794d5a5..bcfdd19f 100644
--- a/scalalib/test/src/mill/scalalib/HelloJavaTests.scala
+++ b/scalalib/test/src/mill/scalalib/HelloJavaTests.scala
@@ -1,8 +1,10 @@
-package mill.scalalib
+package mill
+package scalalib
import ammonite.ops.{%, %%, cp, ls, mkdir, pwd, rm, up}
import ammonite.ops.ImplicitWd._
+import mill.eval.Result
import mill.util.{TestEvaluator, TestUtil}
import utest._
import utest.framework.TestPath
@@ -12,9 +14,17 @@ object HelloJavaTests extends TestSuite {
object HelloJava extends TestUtil.BaseModule{
def millSourcePath = TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.')
- object core extends JavaModule
- object main extends JavaModule{
+ trait JUnitTests extends TestModule{
+ def testFrameworks = Seq("com.novocode.junit.JUnitFramework")
+ def ivyDeps = Agg(ivy"com.novocode:junit-interface:0.11")
+ }
+
+ object core extends JavaModule{
+ object test extends Tests with JUnitTests
+ }
+ object app extends JavaModule{
def moduleDeps = Seq(core)
+ object test extends Tests with JUnitTests
}
}
val resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-java"
@@ -28,12 +38,12 @@ object HelloJavaTests extends TestSuite {
eval
}
def tests: Tests = Tests {
- 'scalaVersion - {
+ 'compile - {
val eval = init()
val Right((res1, n1)) = eval.apply(HelloJava.core.compile)
val Right((res2, 0)) = eval.apply(HelloJava.core.compile)
- val Right((res3, n2)) = eval.apply(HelloJava.main.compile)
+ val Right((res3, n2)) = eval.apply(HelloJava.app.compile)
assert(
res1 == res2,
@@ -49,12 +59,33 @@ object HelloJavaTests extends TestSuite {
val eval = init()
val Right((ref1, _)) = eval.apply(HelloJava.core.docJar)
- val Right((ref2, _)) = eval.apply(HelloJava.main.docJar)
+ val Right((ref2, _)) = eval.apply(HelloJava.app.docJar)
assert(
%%("jar", "tf", ref1.path).out.lines.contains("hello/Core.html"),
%%("jar", "tf", ref2.path).out.lines.contains("hello/Main.html")
)
}
+ 'test - {
+ val eval = init()
+
+ val Left(Result.Failure(ref1, Some(v1))) = eval.apply(HelloJava.core.test.test())
+
+ assert(
+ v1._2(0).fullyQualifiedName == "hello.MyCoreTests.lengthTest",
+ v1._2(0).status == "Success",
+ v1._2(1).fullyQualifiedName == "hello.MyCoreTests.msgTest",
+ v1._2(1).status == "Failure"
+ )
+
+ val Right((v2, _)) = eval.apply(HelloJava.app.test.test())
+
+ assert(
+ v2._2(0).fullyQualifiedName == "hello.MyAppTests.appTest",
+ v2._2(0).status == "Success",
+ v2._2(1).fullyQualifiedName == "hello.MyAppTests.coreTest",
+ v2._2(1).status == "Success"
+ )
+ }
}
}