Skip to content

Manage test framework dependencies in TestModule traits #4968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions example/androidlib/java/1-hello-world/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ object app extends AndroidAppModule {
override def androidVirtualDeviceIdentifier: String = "java-test"

object test extends AndroidAppTests with TestModule.Junit4 {
def testFramework = "com.novocode.junit.JUnitFramework"
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"junit:junit:4.13.2"
)
def junit4Version = "4.13.2"
}

object it extends AndroidAppInstrumentedTests with AndroidTestModule.AndroidJUnit {
Expand Down
7 changes: 1 addition & 6 deletions example/androidlib/java/4-sum-lib-java/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ object app extends AndroidAppModule {
)

object test extends AndroidAppTests with TestModule.Junit4 {
def testFramework = "com.novocode.junit.JUnitFramework"

def mvnDeps = super.mvnDeps() ++ Seq(
mvn"junit:junit:4.13.2"
)

def junit4Version = "4.13.2"
}
}

Expand Down
4 changes: 1 addition & 3 deletions example/androidlib/kotlin/1-hello-kotlin/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ object app extends AndroidAppKotlinModule {
override def androidEmulatorPort: String = "5556"

object test extends AndroidAppKotlinTests with TestModule.Junit4 {
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"junit:junit:4.13.2"
)
def junit4Version = "4.13.2"
}

object it extends AndroidAppKotlinInstrumentedTests with AndroidTestModule.AndroidJUnit {
Expand Down
9 changes: 2 additions & 7 deletions example/androidlib/kotlin/4-sum-lib-kotlin/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ object lib extends AndroidLibKotlinModule with PublishModule {
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }

object test extends AndroidLibKotlinTests with TestModule.Junit4 {
def mvnDeps = super.mvnDeps() ++ Agg(
mvn"junit:junit:4.13.2"
)
def junit4Version = "4.13.2"
}

}
Expand All @@ -73,10 +71,7 @@ object app extends AndroidAppKotlinModule {
)

object test extends AndroidAppKotlinTests with TestModule.Junit4 {
def testFramework = "com.novocode.junit.JUnitFramework"
def mvnDeps = super.mvnDeps() ++ Agg(
mvn"junit:junit:4.13.2"
)
def junit4Version = "4.13.2"
}
}

Expand Down
7 changes: 4 additions & 3 deletions example/scalalib/testing/1-test-suite/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package build
import mill._, scalalib._

object foo extends ScalaModule {
def scalaVersion = "2.13.8"
def scalaVersion = "2.13.15"
object test extends ScalaTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
Expand Down Expand Up @@ -55,6 +55,7 @@ compiling 2 ... source...
// * `TestModule.ScalaTest`, using https://github.com/scalatest/scalatest[ScalaTest]
// * `TestModule.Specs2`, using https://github.com/etorreborre/specs2[Specs2]
// * `TestModule.Utest`, using https://github.com/com-lihaoyi/utest[uTest]
// * `TestModule.Waever`, using https://github.com/disneystreaming/weaver-test[Weaver]
// * `TestModule.ZioTest`, using https://zio.dev/reference/test/[ZioTest]
//
// Each testing framework has their own flags and configuration options that are
Expand All @@ -63,10 +64,10 @@ compiling 2 ... source...
//
//// SNIPPET:BUILD2
object bar extends ScalaModule {
def scalaVersion = "2.13.8"
def scalaVersion = "2.13.15"

object test extends ScalaTests with TestModule.Utest {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def utestVersion = "0.8.5"
}
}

Expand Down
10 changes: 4 additions & 6 deletions example/scalalib/testing/2-test-deps/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@ object qux extends ScalaModule {
def scalaVersion = "2.13.8"
def moduleDeps = Seq(baz)

object test extends ScalaTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
object test extends ScalaTests with TestModule.Utest {
def utestVersion = "0.8.5"
def moduleDeps = super.moduleDeps ++ Seq(baz.test)
}
}

object baz extends ScalaModule {
def scalaVersion = "2.13.8"

object test extends ScalaTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
object test extends ScalaTests with TestModule.Utest {
def utestVersion = "0.8.5"
}
}

Expand Down
4 changes: 2 additions & 2 deletions example/scalalib/testing/3-integration-suite/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ object qux extends ScalaModule {
def scalaVersion = "2.13.8"

object test extends ScalaTests with TestModule.Utest {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def utestVersion = "0.8.5"
}
object integration extends ScalaTests with TestModule.Utest {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def utestVersion = "0.8.5"
}
}
//// SNIPPET:END
Expand Down
7 changes: 3 additions & 4 deletions example/scalalib/testing/4-test-parallel/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import mill._, scalalib._

object foo extends ScalaModule {
def scalaVersion = "2.13.8"
object test extends ScalaTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
object test extends ScalaTests with TestModule.Utest {
def utestVersion = "0.8.5"

def testParallelism = true
}
Expand All @@ -24,7 +23,7 @@ object foo extends ScalaModule {

/** Usage

> mill -j 3 foo.test
> mill --jobs 3 foo.test

> find out/foo/test/testForked.dest
...
Expand Down
6 changes: 3 additions & 3 deletions example/scalalib/testing/5-test-grouping/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import mill._, scalalib._

object foo extends ScalaModule {
def scalaVersion = "2.13.8"
object test extends ScalaTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
object test extends ScalaTests with TestModule.Utest {
def utestVersion = "0.8.5"

def testForkGrouping = discoveredTestClasses().grouped(1).toSeq
def testParallelism = false
}
Expand Down
7 changes: 3 additions & 4 deletions example/scalalib/testing/6-test-group-parallel/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import mill._, scalalib._

object foo extends ScalaModule {
def scalaVersion = "2.13.8"
object test extends ScalaTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
object test extends ScalaTests with TestModule.Utest {
def utestVersion = "0.8.5"

// Group tests by GroupX and GroupY
def testForkGrouping =
Expand All @@ -23,7 +22,7 @@ object foo extends ScalaModule {

/** Usage

> mill -j 4 foo.test
> mill --jobs 4 foo.test

> find out/foo/test/testForked.dest
...
Expand Down
4 changes: 1 addition & 3 deletions example/scalalib/web/1-todo-webapp/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ object `package` extends RootModule with ScalaModule {
mvn"com.lihaoyi::scalatags:0.13.1"
)

object test extends ScalaTests {
def testFramework = "utest.runner.Framework"

object test extends ScalaTests with TestModule.Utest {
def mvnDeps = Seq(
mvn"com.lihaoyi::utest::0.8.5",
mvn"com.lihaoyi::requests::0.6.9"
Expand Down
3 changes: 1 addition & 2 deletions example/scalalib/web/2-webapp-cache-busting/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ object `package` extends RootModule with ScalaModule {
Seq(PathRef(Task.dest))
}

object test extends ScalaTests {
def testFramework = "utest.runner.Framework"
object test extends ScalaTests with TestModule.Utest {
def mvnDeps = Seq(
mvn"com.lihaoyi::utest::0.8.5",
mvn"com.lihaoyi::requests::0.6.9"
Expand Down
4 changes: 1 addition & 3 deletions example/scalalib/web/3-todo-http4s/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ object `package` extends RootModule with ScalaModule {
mvn"io.circe::circe-generic::0.14.10"
)

object test extends ScalaTests {
def testFramework = "utest.runner.Framework"

object test extends ScalaTests with TestModule.Utest {
def mvnDeps = Seq(
mvn"com.lihaoyi::utest::0.8.5",
mvn"org.typelevel::cats-effect-testing-utest::1.6.0",
Expand Down
5 changes: 2 additions & 3 deletions example/scalalib/web/4-scalajs-module/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ object foo extends ScalaJSModule {
def scalaVersion = "2.13.14"
def scalaJSVersion = "1.16.0"
def mvnDeps = Seq(mvn"com.lihaoyi::scalatags::0.13.1")
object test extends ScalaJSTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest::0.8.5")
def testFramework = "utest.runner.Framework"
object test extends ScalaJSTests with TestModule.Utest {
def utestVersion = "0.8.5"
}
}

Expand Down
6 changes: 2 additions & 4 deletions example/scalalib/web/5-webapp-scalajs/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ object `package` extends RootModule with ScalaModule {
super.resources() ++ Seq(PathRef(Task.dest))
}

object test extends ScalaTests {
def testFramework = "utest.runner.Framework"

object test extends ScalaTests with TestModule.Utest {
def utestVersion = "0.8.5"
def mvnDeps = Seq(
mvn"com.lihaoyi::utest::0.8.5",
mvn"com.lihaoyi::requests::0.6.9"
)
}
Expand Down
3 changes: 1 addition & 2 deletions example/scalalib/web/6-webapp-scalajs-shared/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ object `package` extends RootModule with AppScalaModule {
}

object test extends ScalaTests with TestModule.Utest {

def utestVersion = "0.8.5"
def mvnDeps = Seq(
mvn"com.lihaoyi::utest::0.8.5",
mvn"com.lihaoyi::requests::0.6.9"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ trait FooModule extends Cross.Module[String] {
def mvnDeps = Seq(mvn"com.lihaoyi::scalatags::0.13.1")
}

trait FooTestModule extends TestModule {
def mvnDeps = Seq(mvn"com.lihaoyi::utest::0.8.5")
def testFramework = "utest.runner.Framework"
trait FooTestModule extends TestModule.Utest {
def utestVersion = "0.8.5"
}

trait SharedJS extends Shared with ScalaJSModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ trait Shared extends CrossScalaModule with PlatformScalaModule with PublishModul
def mvnDeps = Seq(mvn"com.lihaoyi::scalatags::0.13.1")
}

trait SharedTestModule extends TestModule {
def mvnDeps = Seq(mvn"com.lihaoyi::utest::0.8.5")
def testFramework = "utest.runner.Framework"
trait SharedTestModule extends TestModule.Utest {
def utestVersion = "0.8.5"
}

trait SharedJS extends Shared with ScalaJSModule {
Expand Down
2 changes: 1 addition & 1 deletion example/thirdparty/fansi/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait FansiModule extends PublishModule with CrossScalaModule with PlatformScala
def mvnDeps = Seq(mvn"com.lihaoyi::sourcecode::0.3.0")

trait FansiTests extends ScalaTests with TestModule.Utest {
def mvnDeps = Seq(mvn"com.lihaoyi::utest::0.8.5")
def utestVersion = "0.8.5"
}
}

Expand Down
7 changes: 2 additions & 5 deletions example/thirdparty/jimfs/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ object jimfs extends PublishModule with MavenModule {

def javacOptions = Seq("-processor", "com.google.auto.service.processor.AutoServiceProcessor")

object test extends MavenTests {
object test extends MavenTests with TestModule.Junit4 {
def junit4Version = "4.13.2"
def mvnDeps = sharedCompileMvnDeps() ++ Seq(
mvn"junit:junit:4.13.2",
mvn"com.google.guava:guava-testlib:31.1-android",
mvn"com.google.truth:truth:1.1.3",
mvn"com.github.sbt:junit-interface:0.13.2",
mvn"com.ibm.icu:icu4j:73.1"
)

def testFramework = "com.novocode.junit.JUnitFramework"
}
}

Expand Down
1 change: 0 additions & 1 deletion example/thirdparty/netty/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ trait NettyBaseModule extends MavenModule {
}
trait NettyBaseTestSuiteModule extends NettyBaseModule with TestModule.Junit5 {
def testSandboxWorkingDir = false
def testFramework = "com.github.sbt.junit.jupiter.api.JupiterFramework"
def mvnDeps = Seq(
mvn"com.github.sbt.junit:jupiter-interface:0.11.2",
mvn"org.hamcrest:hamcrest-library:1.3",
Expand Down
10 changes: 4 additions & 6 deletions libs/scalajslib/test/src/mill/scalajslib/CompileLinkTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ object CompileLinkTests extends TestSuite {
)

object `test-utest` extends ScalaJSTests with TestModule.Utest {
override def sources = Task.Sources { this.moduleDir / "src/utest" }
val utestVersion = if (JvmWorkerUtil.isScala3(crossScalaVersion)) "0.7.7" else "0.7.5"
override def mvnDeps = Seq(
mvn"com.lihaoyi::utest::$utestVersion"
)
override def sources = Task.Sources { "src/utest" }
override def utestVersion =
if (JvmWorkerUtil.isScala3(crossScalaVersion)) "0.7.7" else "0.7.5"
}

object `test-scalatest` extends ScalaJSTests with TestModule.ScalaTest {
override def sources = Task.Sources { this.moduleDir / "src/scalatest" }
override def sources = Task.Sources { "src/scalatest" }
override def mvnDeps = Seq(
mvn"org.scalatest::scalatest::3.1.2"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ object MultiModuleTests extends TestSuite {
override def moduleDeps = Seq(shared)
override def mainClass = Some("Main")
object test extends ScalaJSTests with TestModule.Utest {
override def mvnDeps =
Seq(mvn"com.lihaoyi::utest::${sys.props.getOrElse("TEST_UTEST_VERSION", ???)}")
override def utestVersion = sys.props.getOrElse("TEST_UTEST_VERSION", ???)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import scala.util.Properties
object NodeJSConfigTests extends TestSuite {
val scalaVersion = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???)
val scalaJSVersion = sys.props.getOrElse("TEST_SCALAJS_VERSION", ???)
val utestVersion = sys.props.getOrElse("TEST_UTEST_VERSION", ???)
val testUtestVersion = sys.props.getOrElse("TEST_UTEST_VERSION", ???)
val nodeArgsEmpty = List()
val nodeArgs2G = List("--max-old-space-size=2048")
val nodeArgs4G = List("--max-old-space-size=4096")
Expand Down Expand Up @@ -44,9 +44,7 @@ object NodeJSConfigTests extends TestSuite {

object `test-utest` extends ScalaJSTests with TestModule.Utest {
override def sources = Task.Sources { this.moduleDir / "src/utest" }
override def mvnDeps = Seq(
mvn"com.lihaoyi::utest::$utestVersion"
)
override def utestVersion = testUtestVersion
override def jsEnvConfig = Task { JsEnvConfig.NodeJs(args = nodeArgs) }
}
}
Expand Down
Loading
Loading