-
-
Notifications
You must be signed in to change notification settings - Fork 401
/
Copy pathbuild.mill
153 lines (122 loc) · 4.96 KB
/
build.mill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//// SNIPPET:BUILD1
package build
import mill._, scalalib._
object foo extends ScalaModule {
def scalaVersion = "2.13.15"
object test extends ScalaTests {
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
def testFramework = "utest.runner.Framework"
}
}
/** See Also: foo/src/Foo.scala */
/** See Also: foo/test/src/FooTests.scala */
// This build defines a single module with a test suite, configured to use
// "uTest" as the testing framework. Test suites are themselves ``ScalaModule``s,
// nested within the enclosing module,
//// SNIPPET:END
// and have all the normal tasks like
// `foo.test.compile` available to run, but with an additional `.test` task
// that runs the tests. You can also run the test suite directly, in which case
// it will run the `.test` task as the default task for that module.
/** Usage
> mill foo.compile
compiling 1 ... source...
> mill foo.test.compile
compiling 2 ... source...
> mill foo.test.testForked
...foo.FooTests...hello ...
...foo.FooTests...world ...
...foo.FooMoreTests...hello ...
...foo.FooMoreTests...world ...
> mill foo.test # same as above, `.test` is the default task for the `test` module
...foo.FooTests...hello ...
...foo.FooTests...world ...
> mill foo.test.testOnly foo.FooTests # explicitly select the test class you wish to run
...foo.FooTests...hello ...
...foo.FooTests...world ...
*/
// For convenience, you can also use one of the predefined test frameworks:
//
// * `TestModule.Junit4`, using https://github.com/sbt/junit-interface[sbt/junit-interface]
// * `TestModule.Junit5`, using https://github.com/sbt/sbt-jupiter-interface[sbt/sbt-jupiter-interface]
// * `TestModule.TestNg`, using https://testng.org/[TestNg]
// * `TestModule.Munit`, using https://github.com/scalameta/munit[munit]
// * `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.ZioTest`, using https://zio.dev/reference/test/[ZioTest]
//
// Each testing framework has their own flags and configuration options that are
// documented on their respective websites, so please see the links above for more
// details on how to use each one from the command line.
//
//// SNIPPET:BUILD2
object bar extends ScalaModule {
def scalaVersion = "2.13.15"
object test extends ScalaTests with TestModule.Utest {
def utestVersion = "0.8.5"
}
}
//// SNIPPET:END
/** Usage
> mill bar.test
...bar.BarTests...hello ...
...bar.BarTests...world ...
*/
// You can also select multiple test suites in one command using Mill's
// xref:cli/query-syntax.adoc[Task Query Syntax]
/** Usage
> mill __.test
...bar.BarTests...hello ...
...bar.BarTests...world ...
...foo.FooTests...hello ...
...foo.FooTests...world ...
...
*/
// Mill provides three ways of running tests
/** Usage
> mill foo.test
*/
// `foo.test`: runs tests in a subprocess in an empty `sandbox/` folder. This is short
// for `foo.test.testForked`, as `testForked` is the default task for ``TestModule``s.
/** Usage
> mill foo.test.testCached
*/
// `foo.test.testCached`: runs the tests in an empty `sandbox/` folder and caches the results
// if successful. This can be handy if you are you working on some upstream modules and only
// want to run downstream tests which are affected: using `testCached`, downstream tests which
// are not affected will be cached after the first run and not re-run unless you change some
// file upstream of them.
//
/** Usage
> mill foo.test.testLocal
*/
// `foo.test.testLocal`: runs tests in an isolated classloader as part of the main Mill process.
// This can be faster than `.test`, but is less flexible (e.g. you cannot pass `forkEnv`)
// and more prone to interference (`testLocal` runs do not run in xref:depth/sandboxing.adoc[sandbox folders])
//
// It is common to run tests with xref:cli/flags.adoc#_watch_w[-w/--watch]
// enabled, so that once you edit a file on disk the selected tests get re-run.
//
// NOTE: Mill runs tests with the working directory set to an empty
// xref:depth/sandboxing.adoc[sandbox/ folder] by default.
// Tests can access files from their resource directory via the environment variable
// `MILL_TEST_RESOURCE_DIR` which provides the path to the resource folder, and additional
// paths can be provided to test via `forkEnv`. See
// xref:javalib/module-config.adoc#_classpath_and_filesystem_resources[Classpath and Filesystem Resources]
// for more details.
//
// If you want to pass any arguments to the test framework, you can pass them after
// `foo.test` in the command line. e.g. {utest-github-url}[uTest]
// lets you pass in a selector to decide which test to run, which in Mill would be:
//// SNIPPET:RUNSINGLE
/** Usage
> mill foo.test foo.FooMoreTests
...foo.FooMoreTests...hello ...
*/
//// SNIPPET:END
/** Usage
> mill bar.test bar.BarTests.hello
...bar.BarTests...hello ...
*/
// This command only runs the `hello` test case in the `bar.BarTests` test suite class.