0
我有这样的单元测试:“不是一个法律形式参数”
class MyServiceSpec extends WordSpec
with Matchers
with MockitoSugar
with BeforeAndAfterEach {
"MyService" must {
"succeed if my-endpoint succeeds" in {
Server.withRouter() {
GET("/my-endpoint") => Action {
Results.Ok.sendResource("myservice/my-endpoint.txt")
}
} { implicit port =>
WsTestClient.withClient { client =>
val result = Await.result(
new RealMyService(client).getFromEndpoint(), 10.seconds)
result shouldEqual true
}
}
}
}
}
sbt
告诉我:
» sbt test-only MyService
...
[error] /repos/myrepo/test/services/MyServiceSpec.scala:34: not a legal formal parameter.
[error] Note: Tuples cannot be directly destructured in method or function parameters.
[error] Either create a single parameter accepting the Tuple1,
[error] or consider a pattern matching anonymous function: `{ case (param1, param1) => ... }
[error] GET("/my-endpoint") => Action {
[error] ^
[error] one error found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 3 s, completed Jun 16, 2017 7:27:11 AM
和IntelliJ告诉我:
Application does not take parameters: } expected
上线:
GET("/my-endpoint") => Action {
这究竟意味着什么?
谢谢!我意外删除了“case”关键字,并且再也没有注意到。虽然'sbt'和'IntelliJ'都不是很有帮助。 – dangonfast
我看到你的痛苦,但另一方面,sbt似乎对我很有帮助。而不是有一个正式的参数,你有一个要评估的声明。这就像是说'(1 + 2)=>什么是一个函数。但无论如何,很高兴你把它整理出来。 :) – slouc
现在你提到它,'sbt'就是关键,但是我的思想顽固地拒绝了'sbt'提示中'case'关键字的确认!现在看,它似乎很明显......我应该采取一个课程“如何阅读错误信息,而不会错过重要的零碎件” – dangonfast