Vladimir Matveev
unread,Jul 15, 2013, 8:49:39 AM7/15/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scalate...@googlegroups.com
Hi,
According to the official docs and API docs when using ShouldMatchers it is possible to use word be for equality comparison to produce more readable tests:
result should be (null)
However, this does not compile when result is not AnyRef but Any. But it is perfectly correct to check Any value for null:
ConvertToMap.convert(YNullable(YString), "123") should equal ("123")
ConvertToMap.convert(YNullable(YString), null) should be (null)
convert() method here returns Any, and it is wholly possible for it to return null. But the compiler rejects this code with the following message:
overloaded method value should with alternatives:
(notWord: ConvertToMapTest.this.NotWord)ConvertToMapTest.this.ResultOfNotWord[Any] <and>
(rightMatcher: org.scalatest.matchers.Matcher[Any])Unit
cannot be applied to (org.scalatest.matchers.Matcher[AnyRef])
ConvertToMap.convert(YNullable(YString), null) should be (null)
^
I understand I can use equal word but it doesn't feel right:
ConvertToMap.convert(YNullable(YString), null) should equal (null)
Is it possible to use be word somehow in my case?
Best regards,
Vladimir.