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.
Execute a Single Test Class The Maven surefire plugin provides a test parameter that we can use to specify test classes or methods we want to execute. If we want to execute a single test class, we can execute the command mvn test -Dtest=”TestClassName”.
A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With