当我按照 sbt-toplecat 打开编译器标志时,我收到以下编译器错误。
await(myService(request).value).isLeft shouldBe true
现在编译器抱怨:
discarded non-Unit value
await(myService(request).value).isLeft shouldBe true
^
这个应该匹配器来自Scalatest:
def shouldBe(right: Any): Assertion = {
if (!areEqualComparingArraysStructurally(leftSideValue, right)) {
val (leftee, rightee) = Suite.getObjectsForFailureMessage(leftSideValue, right)
val localPrettifier = prettifier // Grabbing a local copy so we don't attempt to serialize AnyShouldWrapper (since first param to indicateFailure is a by-name)
indicateFailure(FailureMessages.wasNotEqualTo(localPrettifier, leftee, rightee), None, pos)t
}
else indicateSuccess(FailureMessages.wasEqualTo(prettifier, leftSideValue, right))
}
我需要做什么来解决这个问题?显然,断言是真的还是假的,所以我总是得到一个非单位值,然后被丢弃。
考虑放宽编译器标志以进行测试配置,因为此代码不在生产环境中运行。也许只是简单地显式设置一些您可能喜欢的测试配置标志,如下所示
Test / scalacOptions := Seq(
// few flags I want for tests
)