How to execute tests in a single project only in multi-module build?
I have a multi-module build, and would like to run tests for different sub-projects independently.
Is there a way to do this in sbt, e.g. if my multi-project build has a core
and commons
projects, I'd like to only run test
in the commons
project.
Run sbt commons/test
. See detailed explanation in Scopes.
You may also use the combination of two commands from sbt - changing the current project using project
and executing test
afterwards.
sbt "project commons" test
You can also use
sbt "; project commons; test"
It you are running sbt
in interactive mode:
> project commons
> test
You can switch back to core
with:
> project core
Never mind, I came across this: How to execute package for one submodule only on Jenkins?
sbt "project core" test
Another way to do this.
Get into SBT interactive mode
> sbt
sbt:core> commons / test
No need to switch between projects.
to run sbt test only for ONLY the submodules having added, modified on deleted files, if you use git:
while read -r proj ; do sbt "project $proj" test ; \
done < <(git status --porcelain | cut -c 3- | cut -d/ -f1