I am relatively new to Scala Test, and so I consulted the documentation on how to test on Either
values.
I tried to replicate the instructions like that:
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
class EitherTest extends AnyFlatSpec with EitherValues {
val either: Either[Exception, Int] = Right(42)
either.right.value should be > 1
}
This implementation does not do the trick, I get a syntax error. What did I do wrong?
Error:
Error:(9, 22) value should is not a member of Int
either.right.value should be > 1
Error:(9, 29) not found: value be
either.right.value should be > 1
Error:(9, 22) value should is not a member of Int either.right.value should be > 1 Error:(9, 29) not found: value be either.right.value should be > 1
– Fondaval either = Right(42)
– KalimantanMatchers
(egclass EitherTest extends AnyFlatSpec with EitherValues with Matchers
). – Rhyneorg.scalatest.matchers.should.Matchers
got rid of the syntax error but my IDE still states thatEither.right
is deprecated since Scala 2.13.0, Is that expected? – Fondawith OptionValues
instead and theneither.toOption.value
. – Zeculon