'Cannot resolve symbol should' - why?

3,665 views
Skip to first unread message

Eric Fowler

unread,
Dec 27, 2014, 8:50:34 PM12/27/14
to scalate...@googlegroups.com
I have an SBT project in in Intellij IDEA with a test directory in the usual place, and scalatest and scalautils designated as external libraries. 

IDEA is flagging 'should' and 'in' with red text, and saying it can't resolve them. 

How can I set up scalatest to run in this environment? Where is 'should' defined?

Mind, I am pretty new to scalatest and IDEA. 

Thanks

Eric

Eric Fowler

unread,
Dec 27, 2014, 8:59:08 PM12/27/14
to scalate...@googlegroups.com
This has also appeared on the command line:

C:\Users\Eric\Scala\SBT\src\test\scala>scalac -cp "c:\users\Eric\Downloads\scala
test_2.10-1.9.1 (1).jar" sbt0_test.scala
sbt0_test.scala:16: error: value should is not a member of Int
    stack.pop() should be (2)
                ^
sbt0_test.scala:17: error: value should is not a member of Int
    stack.pop() should be (1)
                ^
sbt0_test.scala:23: error: missing arguments for method apply in class AWord;
follow this method with `_' if you want to treat it as a partially applied funct
ion
    a [NoSuchElementException] should be thrownBy {
      ^
three errors found

C:\Users\Eric\Scala\SBT\src\test\scala>scalac -cp "c:\users\Eric\Downloads\scala
test_2.10-1.9.1 (1).jar" org.scalatest.run sbt0_test.scala
error: source file 'org.scalatest.run' could not be found
one error found

C:\Users\Eric\Scala\SBT\src\test\scala>

Marco Massenzio

unread,
Dec 29, 2014, 10:12:16 PM12/29/14
to scalate...@googlegroups.com
IntelliJ is not at its best when auto-detecting the necessary imports for things like `should` etc in Scala (I mean, as compared to its fantastic-outstanding self when doing the same for Java).

You are most likely missing this import:
import org.scalatest._

(see the code here, and here for a full example).

I have had some trouble getting the whole thing to work in Scala, so you may also want to check out my build.sbt and friends.

Hope this helps.

On Saturday, December 27, 2014 5:50:34 PM UTC-8, Eric Fowler wrote:

Bill Venners

unread,
Dec 30, 2014, 12:25:12 PM12/30/14
to scalate...@googlegroups.com
Hi Eric,

Another possibility is you didn't mix in Matchers or import Matchers._. The implicit conversion that adds should to any type is in org.scalatest.Matchers, which is not mixed into style traits by default.

Bill
Reply all
Reply to author
Forward
0 new messages