Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute tests in a single project only in multi-module build?

Tags:

sbt

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.

like image 247
Brett Avatar asked Feb 06 '14 10:02

Brett


People also ask

How do you run an individual test case?

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”.

What is multi-module project?

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.


2 Answers

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" 
like image 94
Jacek Laskowski Avatar answered Sep 19 '22 19:09

Jacek Laskowski


It you are running sbt in interactive mode:

> project commons > test 

You can switch back to core with:

> project core 
like image 22
mixel Avatar answered Sep 20 '22 19:09

mixel