Mill Service Module
Extends mill to allow defining services and running tests which require services.
-
Declare your services and tests
import $ivy.`io.inpher::mill-services::0.1.0` import mill._ import mill.services.ServiceModule import mill.services.TestWithServices object service1 extends ScalaModule with ServiceModule { def serviceExec = assembly() def serviceHealthCheck = ServiceModule.HealthCheck.Http("http://localhost:2000/health") } object service2 extends ScalaModule with ServiceModule { def serviceExec = assembly() def serviceHealthCheck = ServiceModule.HealthCheck.Http("http://localhost:2001/health") def serviceDeps = Agg(service1) } object test extends ScalaTests with TestWithServices { def serviceDeps = Agg(service2) }
-
Run tests as usual
./mill test
This will start all services and wait for them to be ready before running tests, and tear down services when mill exits.
Inspired by this talk. A word of caution: this is intended to be used for small- to medium-sized projects which can reasonably spin up a whole environment of services on a single machine.
License
Copyright 2023 Inpher, Inc
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.