Reputation: 1202
I am getting the following compiler error as I switched on the compiler flags as per sbt-toplecat.
await(myService(request).value).isLeft shouldBe true
Now compiler complains:
discarded non-Unit value
await(myService(request).value).isLeft shouldBe true
^
This shouldBe matcher is from 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))
}
What do I need to do to resolve this? Obviously the assertion will be true or false so I always get a non-Unit value which is then discarded.
Upvotes: 1
Views: 929
Reputation: 11
For an sbt project to work in IntelliJ, I had to add this:
"-Wconf:msg=unused value of type org.scalatest.Assertion:s",
"-Wconf:msg=unused value of type org.specs2.specification.core.Fragment:s",
"-Wconf:msg=unused value of type org.specs2.matcher.MatchResult:s",
"-Wconf:msg=unused value of type org.scalamock:s"
I guess you got the point. Everywhere you see a warning, add the problematic warning to Compile / scalacOptions
in build.sbt
Upvotes: 1
Reputation: 48430
Consider relaxing compiler flags for test confguration as this code is not run in production. Maybe simply explicitly set few flags you might like for test configuraiton like so
Test / scalacOptions := Seq(
// few flags I want for tests
)
Upvotes: 1