Stave Escura
Stave Escura

Reputation: 2098

Where do I put my tests when I split my Play project into sub modules

Software stack:

I have a monolithic Play application that I am splitting into sub modules. I have a number of unit and integration tests that are currently in the /test folder of the project root.

I am splitting it into two main modules 'audit' and 'users'. The directory structure is currently like this

/
/conf  -- application.conf & routes which references the child module route files 
/module
/module/user
/module/user/app   -- here I have UserController and some model code
/module/user/conf  -- here I have user.Routes
/module/audit
/module/audit/app  -- here I have AuditController and some model code
/module/audit/conf -- here I have audit.Routes
/test

The tests (a mixture of unit tests and selenium integration tests) are currently in /tests. I would like to move the unit tests to their modules. I've tried the 'obvious': for audit I put them in /module/audit/test and /module/audit/src/test/scala. In SBT I've tried 'inspect scalaSource' which tells me the directory for tests for the audit module is ...preamble.../module/audit/test

Unfortunately when I try 'test' in SBT, the tests in the child module are not being picked up. I've tried adding the following to the audit module

scalaSource in Test := baseDirectory.value / "src" / "test" / "scala"

By 'not being picked up' I mean 'compilation errors in the files are not being detected' and 'tests are not executed'. In otherwords the "scalaSource in Test" key doesn't seem to be used

What is the recommended way to do this for Play framework projects?

Upvotes: 4

Views: 264

Answers (1)

Nyavro
Nyavro

Reputation: 8866

If your tests not gets executed by test command, probably your project not configured correctly. Normally multi project sbt aggregates subprojects:

lazy val parent = Project(
  id = "parent",
  base = file("."),
  settings = ...
).aggregate(audit, users)

Upvotes: 1

Related Questions