minifigmaster125
minifigmaster125

Reputation: 175

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.

Upvotes: 2

Views: 3376

Answers (3)

Jonio
Jonio

Reputation: 1293

I solve with the command sbt clean compile

Upvotes: 5

Daniel
Daniel

Reputation: 1416

I can see this problem is solved, but I had this happen for a very different reason. I added the play framework to an existing project, by adding the sbt plugin and enabling it, and my tests stopped running. Probably the project was not compiling either but I didn't notice since the tests didn't run. The play framework sbt plugin seems to mess with the source dirs, I had to do this to put it back how it was:

lazy val root = (project in file("."))
  .enablePlugins(PlayService, PlayLayoutPlugin)
  .settings(
    name := "Coffee",
    scalaSource in Test := baseDirectory.value / "src/test/scala",
    scalaSource in Compile := baseDirectory.value / "src/main/scala"
  )

Seems very rude!

Upvotes: 0

metaphori
metaphori

Reputation: 2811

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.

Upvotes: 1

Related Questions