Just started reading Chapter 6 (Akka Testing) of the book.
Made the modification to the sbt dependencies, so my sbt configuration file looks this:
$ more project/Chapter6Build.scala
import sbt._ import sbt.Keys._
object AkkaProjectInScalaBuild extends Build {
lazy val akkaProjectInScala = Project( id = "akka-project-in-scala", base = file("."), settings = Project.defaultSettings ++ Seq( name := "Akka Project In Scala", organization := "org.example", version := "0.1-SNAPSHOT", scalaVersion := "2.10.0", scalacOptions ++= Seq("-feature", "-deprecation"), resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases", libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % "2.0.M5b" % "test", "com.typesafe.akka" %% "akka-testkit" % "2.1.0", "com.typesafe.akka" %% "akka-actor" % "2.1.2" ) ) ) }
Running 'sbt update' and 'sbt compile' give the following:
$ sbt update
[info] Loading project definition from /Users/ericloots/Desktop/Scala course WCopy/Scala/Scala course/Akka/chapter-6/project [info] Updating {file:/Users/ericloots/Desktop/Scala%20course%20WCopy/Scala/Scala%20course/Akka /chapter-6/project/}default-057ea0... [info] Resolving org.scala-sbt#precompiled-2_10_0;0.12.2 ... [info] Done updating. [info] Compiling 1 Scala source to /Users/ericloots/Desktop/Scala course WCopy/Scala/Scala course/Akka/chapter-6/project/target/scala-2.9.2/sbt-0.12/classes... [info] Set current project to Akka Project In Scala (in build file:/Users/ericloots/Desktop/Scala%20course%20WCopy/Scala/Scala%20course/Akka/ chapter-6/) [info] Updating {file:/Users/ericloots/Desktop/Scala%20course%20WCopy/Scala/Scala%20course/Akka /chapter-6/}akka-project-in-scala... [info] Resolving org.scalatest#scalatest_2.10;2.0.M5b ... [info] Done updating. [success] Total time: 0 s, completed Mar 21, 2013 11:51:35 AM
$ sbt compile
[info] Loading project definition from /Users/ericloots/Desktop/Scala course WCopy/Scala/Scala course/Akka/chapter-6/project [info] Set current project to Akka Project In Scala (in build file:/Users/ericloots/Desktop/Scala%20course%20WCopy/Scala/Scala%20course/Akka/ chapter-6/) [info] Compiling 6 Scala sources to /Users/ericloots/Desktop/Scala course WCopy/Scala/Scala course/Akka/chapter-6/target/scala-2.10/classes... [error] /Users/ericloots/Desktop/Scala course WCopy/Scala/Scala course/Akka/chapter-6/src/main/scala/zzz/akka/TestEventSource.scala:5: object scalatest is not a member of package org [error] import org.scalatest.WordSpec [error] ^ [error] one error found [error] (compile:compile) Compilation failed [error] Total time: 3 s, completed Mar 21, 2013 11:52:14 AM
The build configuration states that the scalatest library is provided in the "test" configuration. You've put your "test" code in the "main" source area.
Move the test file into src/test/scala/ instead of src/main/scala.
And, technically, 'sbt compile' won't do anything with the test class now that you've moved it. To compile it, you want 'sbt test:compile' and to test it (as well as compile it) you want 'sbt test'.