I'm trying to get Hello World to get a green test in my hello world scalatra application. The code for the servlet is:
package com.graphular.app
import org.scalatra._
import scalate.ScalateSupport
class MyScalatraServlet extends GraphularStack {
get("/") {
<html>
<body>
<h1>Hello, world!</h1>
Say <a href="hello-scalate">hello to Scalate</a>.
</body>
</html>
}
}
It appears to work in the browser and I'm quite happy with that. I wrote the test for it and is as so:
import org.scalatra.test.scalatest._
import org.scalatest.FunSuite
class MyScalatraServletTests extends ScalatraSuite with FunSuite {
addServlet(classOf[MyScalatraServlet], "/*")
test("simple get") {
get("/") {
status should equal(200)
body should include("hi!")
}
}
}
My libraryDependencies
are:
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar"))
I thought this was going to work, but instead I keep receiving:
[error] /Users/benmorgan/Sites/scala/graphular/src/test/scala/com/graphular/app/MyScalatraServletSpec.scala:7: not found: type MyScalatraServlet
[error] addServlet(classOf[MyScalatraServlet], "/*")
I cannot figure this out for the love of me...
If this is the whole code then you forgot the package statement in your test:
package com.graphular.app
Otherwise you should import the class under test.