Search code examples
scalasbtscalatesttypesafe-activator

SBT can't find tests to run nor compile


As the title says, I've got an sbt project with one module (for now), but the test:compile does not catch any syntax errors (and test doesn't find any tests to run). The way I understand it, an sbt project comes setup with src/main, and src/test (src/it needs to be configured). I'm a bit of an amateur with SBT, but I'll try to give all the relevant info:

Structure:

Root
  build.sbt
  mymodule
    build.sbt
    src
      main
        scala
      test
        scala 

Root build.sbt (I reckon these configs were unecessary but I'm desperate):

lazy val `mymodule` = (project in file("mymodule"))
  .configs(Test)
  .settings(scalaSource in Test := baseDirectory.value / "test")

MyModule build.sbt is basically just a list of libraryDependencies (unless one of them is the problem, not sure) like this:

libraryDependencies ++= Seq(
  "org.mockito" % "mockito-all" % "1.9.5" % "test",
  "org.scalamock" %% "scalamock-core" % scalaMockVersion % "test",
  "org.scalamock" %% "scalamock-scalatest-support" % scalaMockVersion % "test",
  "org.codehaus.janino" % "janino" % "2.7.8",
  "org.http4s" %% "http4s-dsl" % "0.11.2",
  "org.http4s" %% "http4s-blaze-server" % "0.11.2",
  "junit" % "junit" % "4.8.1" % "test" // Here because of a bug in Ivy
)

Let me know what else I can do to help, it's really racking my brain.


Solution

  • With line

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

    you have configured sbt to look up test sources at location Root/mymodule/test (rather than at the default location <base>/src/test/scala).

    So, your options are either (i) to put your tests within Root/mymodule/test, (ii) or to remove that configuration line, leaving tests in their default location.