11# kargo
2- A command-line build tool for kotlin inspired by rust's [ cargo] ( https://doc.rust-lang.org/cargo/ ) .
2+
3+ A command-line build tool for kotlin inspired by rust's [ cargo] ( https://doc.rust-lang.org/cargo/ ) .
34
45# Installation
56
@@ -78,6 +79,7 @@ Builds your project using the kotlin CLI compiler. This will produce a jar file
7879in ` target/<project.name>.jar ` containing your code and the kotlin runtime.
7980
8081### run
82+
8183` kargo run [--script <path to kts script>] [-- <args to main class or script>] `
8284
8385Run the project's main class with the provided args, or alternately the
@@ -116,6 +118,26 @@ any errors.
116118
117119Uses [ ` ktlint ` ] ( https://ktlint.github.io/ ) to format your kotlin sources
118120in-place. This command is known not to work on java 17.
121+ : w
122+
123+ ### test
124+
125+ ` kargo test `
126+ Uses JUnit5 to run the project's tests, which should do annotations / assertions via the
127+ standard ` kotlin.test ` library. (You must also add a
128+ ` org.jetbrains.kotlin:kotlin-test-junit5 ` dependency to ` Kargo.toml ` for test running.)
129+
130+ To avoid confusion / mistakenly thinking that tests passed when they didn't,
131+ this will run ` kargo build ` before running tests.
132+
133+ Test discovery requires some knowledge of project layout. By default, kargo will
134+ discover all test files ending in ` _test.kt ` within the ` src ` directory. To use
135+ the more conventional ` src/{main,test}/kotlin ` project layout, add
136+ ` project_layout = "classic" ` to the package section of the ` Kargo.toml ` file.
137+
138+ It's a known issue that we currently don't discover functions annotated with
139+ @Test at top-level in test files. As a workaround, place them within classes
140+ whose name starts or ends with ` Test ` .
119141
120142## Kargo.toml reference
121143
@@ -131,6 +153,10 @@ in-place. This command is known not to work on java 17.
131153- ` use_serialization_plugin ` (optional, default ` false ` ): if you use
132154 ` kotlinx.serialization ` in your project, set this to ` true ` to enable the
133155 corresponding compiler plugin.
156+ - ` project_layout ` (optional, one of ` classic ` or ` flat ` , default ` flat ` ): project
157+ layout used to discover tests. ` flat ` allows test files alongside code, in
158+ files ending in ` _test.kt ` . ` classic ` uses the more conventional layout where
159+ tests are in ` src/test ` (and non-test code is in ` src/main ` ).
134160
135161` [dependencies] ` : this section is required but can be empty
136162
@@ -151,15 +177,18 @@ itself.
151177
152178### Short-term
153179
154- - ` kargo test ` for running tests (and exclusion of test files from builds, etc.)
180+ - test configuration options for running tests by tag, or specific tests
181+ - test discovery for top-level functions
155182- a number of other configuration options (option to turn off including the
156183 kotlin runtime in the jar, support of other source / test layouts, etc.)
157184
158185### Medium-term
186+
159187- better support for building / publishing libraries, rather than just runnable
160188 applications
161189
162190### Long-term
191+
163192- kotlin js/native support
164193
165194## License
0 commit comments