From 04be10397d3a33532c4ecd84ce12ba05eb717c4d Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Tue, 11 Apr 2023 13:48:04 -0300 Subject: [PATCH 1/4] Add zio-test to TestModule --- docs/antora/modules/ROOT/pages/Configuration.adoc | 1 + readme.adoc | 2 +- scalalib/src/mill/scalalib/TestModule.scala | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/antora/modules/ROOT/pages/Configuration.adoc b/docs/antora/modules/ROOT/pages/Configuration.adoc index eafcdcfabea..ce53cda81c2 100644 --- a/docs/antora/modules/ROOT/pages/Configuration.adoc +++ b/docs/antora/modules/ROOT/pages/Configuration.adoc @@ -190,6 +190,7 @@ For convenience, you can also use one of the predefined test frameworks: * `TestModule.ScalaTest` * `TestModule.Specs2` * `TestModule.Utest` +* `TestModule.ZIOTest` .`build.sc`: `ScalaModule` with UTest tests using the predefined `TestModule.Utest` diff --git a/readme.adoc b/readme.adoc index 67d76cd5feb..6a9b49da96d 100644 --- a/readme.adoc +++ b/readme.adoc @@ -932,7 +932,7 @@ _Changes since {prev-version}:_ * `ScalaModule`: Support for Scala 3 * `CoursierModule`: Support customized dependency resolution (needed to work with ScalaFX) * `TestModule`: Added new `testFramework` target and only support one test framework. Deprecated `testFrameworks` targets. -* `TestModule`: Added new convenience traits to configure popular test frameworks, e.g. `TestModule.Junit4`, `TestModule.ScalaTest`, `TestModule.Utest`, and many more +* `TestModule`: Added new convenience traits to configure popular test frameworks, e.g. `TestModule.Junit4`, `TestModule.ScalaTest`, `TestModule.Utest`, `TestModule.ZIOTest` and many more * `Bloop`: Added support for foreign modules * Better support for Windows environments * Various internal improvements, cleanups, and deprecations diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index 5a808f3eff8..a9c2e55d416 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -242,6 +242,14 @@ object TestModule { override def testFramework: T[String] = "weaver.framework.CatsEffect" } + /** + * TestModule that uses ZIO Test Framework to run tests. + * You need to provide the zio-test dependencies yourself. + */ + trait ZIOTest extends TestModule + override def testFramework: T[String] = "zio.test.sbt.ZTestFramework" + } + @deprecated("Use other overload instead", "Mill after 0.10.2") def handleResults( doneMsg: String, From 01b4148fea5a3814113148eee4683a62e213e86c Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Wed, 12 Apr 2023 10:04:22 -0300 Subject: [PATCH 2/4] Add ZIO-test example --- .../modules/ROOT/pages/Configuration.adoc | 19 +++++++++++++++++++ readme.adoc | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/antora/modules/ROOT/pages/Configuration.adoc b/docs/antora/modules/ROOT/pages/Configuration.adoc index ce53cda81c2..c334e697d3b 100644 --- a/docs/antora/modules/ROOT/pages/Configuration.adoc +++ b/docs/antora/modules/ROOT/pages/Configuration.adoc @@ -321,6 +321,25 @@ object foo extends ScalaModule { } ---- +ZIO-test example: + +.`build.sc` +[source,scala,subs="attributes,verbatim"] +---- +import mill._, scalalib._ + +object foo extends ScalaModule { + def scalaVersion = "{example-scala-3-version}" + + object test extends Tests with TestModule.ZIOTest { + def ivyDeps = Agg( + ivy"dev.zio::zio-test:2.0.12", + ivy"dev.zio::zio-test-sbt:2.0.12", + ) + } +} +---- + After that, you can follow the instructions in <<_adding_a_test_suite>>, and use `mill foo.test` as usual, or pass args to the test suite via `mill foo.test arg1 arg2 arg3`. == Scala Compiler Plugins diff --git a/readme.adoc b/readme.adoc index 6a9b49da96d..64bc4259525 100644 --- a/readme.adoc +++ b/readme.adoc @@ -932,7 +932,7 @@ _Changes since {prev-version}:_ * `ScalaModule`: Support for Scala 3 * `CoursierModule`: Support customized dependency resolution (needed to work with ScalaFX) * `TestModule`: Added new `testFramework` target and only support one test framework. Deprecated `testFrameworks` targets. -* `TestModule`: Added new convenience traits to configure popular test frameworks, e.g. `TestModule.Junit4`, `TestModule.ScalaTest`, `TestModule.Utest`, `TestModule.ZIOTest` and many more +* `TestModule`: Added new convenience traits to configure popular test frameworks, e.g. `TestModule.Junit4`, `TestModule.ScalaTest`, `TestModule.Utest` and many more * `Bloop`: Added support for foreign modules * Better support for Windows environments * Various internal improvements, cleanups, and deprecations From 2d3454f6cace9ccb36516ffea6bfa3bde5ac1085 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Thu, 13 Apr 2023 14:31:33 -0300 Subject: [PATCH 3/4] Rename trait to be in-line with other traits --- docs/antora/modules/ROOT/pages/Configuration.adoc | 4 ++-- scalalib/src/mill/scalalib/TestModule.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/antora/modules/ROOT/pages/Configuration.adoc b/docs/antora/modules/ROOT/pages/Configuration.adoc index c334e697d3b..a2f4a61cefc 100644 --- a/docs/antora/modules/ROOT/pages/Configuration.adoc +++ b/docs/antora/modules/ROOT/pages/Configuration.adoc @@ -190,7 +190,7 @@ For convenience, you can also use one of the predefined test frameworks: * `TestModule.ScalaTest` * `TestModule.Specs2` * `TestModule.Utest` -* `TestModule.ZIOTest` +* `TestModule.ZioTest` .`build.sc`: `ScalaModule` with UTest tests using the predefined `TestModule.Utest` @@ -331,7 +331,7 @@ import mill._, scalalib._ object foo extends ScalaModule { def scalaVersion = "{example-scala-3-version}" - object test extends Tests with TestModule.ZIOTest { + object test extends Tests with TestModule.ZioTest { def ivyDeps = Agg( ivy"dev.zio::zio-test:2.0.12", ivy"dev.zio::zio-test-sbt:2.0.12", diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index a9c2e55d416..eeadaebd6a9 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -246,7 +246,7 @@ object TestModule { * TestModule that uses ZIO Test Framework to run tests. * You need to provide the zio-test dependencies yourself. */ - trait ZIOTest extends TestModule + trait ZioTest extends TestModule override def testFramework: T[String] = "zio.test.sbt.ZTestFramework" } From 746870beab9ed48a9e5239d50200efbce830baea Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sat, 15 Apr 2023 10:56:55 +0200 Subject: [PATCH 4/4] Fixed missing parenthesis --- scalalib/src/mill/scalalib/TestModule.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index eeadaebd6a9..0d6b9a1c81c 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -246,7 +246,7 @@ object TestModule { * TestModule that uses ZIO Test Framework to run tests. * You need to provide the zio-test dependencies yourself. */ - trait ZioTest extends TestModule + trait ZioTest extends TestModule { override def testFramework: T[String] = "zio.test.sbt.ZTestFramework" }