我知道很多人会说这是在另一个线程上回答的,但我还没有找到这个问题的答案。要么线程被劫持,要么修复不起作用。
我正在使用 IntelliJ IDEA 2016.1 Build #IU-145.258,于 2016 年 3 月 17 日构建
我的 Project SDK 是 1.8.0_73,Scala 版本是 2.11,Play 2 版本是 2.5.0。
我通过右键单击我的项目的测试文件夹并单击调试“所有测试”来从 IDE 运行我的测试。他们都通过了,但我收到以下错误。
java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/jquery-1.9.0.min.js' (status 404).
IOException 发生在 IntegrationSpec.scala 中。任何人都可以帮助解决这个问题吗?
这是我的项目的文件。
提前谢谢你
弗朗西斯
构建.sbt
name := "test"
version := "1.0"
lazy val `test` = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq( jdbc , cache , ws , specs2 % Test )
unmanagedResourceDirectories in Test <+= baseDirectory ( _ /"target/web/public/test" )
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
路线
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
build.properties
sbt.version=0.13.5
插件.sbt
logLevel := Level.Warn
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.0")
应用程序.scala
package controllers
import play.api._
import play.api.mvc._
class Application extends Controller {
def index = Action {
Ok(views.html.index("Your new application is ready."))
}
}
main.scala.html
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
<script src="@routes.Assets.at("javascripts/jquery-1.9.0.min.js")" type="text/javascript"></script>
</head>
<body>
@content
</body>
</html>
IntegrationSpec.scala
import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._
import play.api.test._
import play.api.test.Helpers._
/**
* add your integration spec here.
* An integration test will fire up a whole play application in a real (or headless) browser
*/
@RunWith(classOf[JUnitRunner])
class IntegrationSpec extends Specification {
"Application" should {
"work from within a browser" in new WithBrowser {
browser.goTo("http://localhost:" + port)
browser.pageSource must contain("Your new application is ready.")
}
}
}