Can't Run SBT 'test' with ScalaTest

2,557 views
Skip to first unread message

Kevin Meredith

unread,
Feb 4, 2014, 5:24:50 PM2/4/14
to scalate...@googlegroups.com

src/main/scala/Testing.scala

package common
object Add1Method {
  def main(args: Array[String]) = 100+2
  }

project/build.sbt

name := "Foo"

version := "1.0"

scalaVersion := "2.10.2"

libraryDependencies += "org.scalatest" % "scalatest_2.10" % "1.9.1" % "test"

resolvers +=  "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

resolvers +=  "Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases"

src/test/scala/Test.scala

package test

import common.Testing
import org.scalatest._

class TestAdd1 extends FlatSpec with Matchers {

      "Adding 1 to Array(1)" should "return in Some(2)" in {
        val result = Add1Method.main(Array("asdf"))
        assert(result == 102)
      }
    }

But, when I run test from SBT, the following 4 compile-time errors:

[error] Test.scala:4: object scalatest is not a member of package org
[error] import org.scalatest._
[error]            ^
[error] Test.scala:6: not found: type FlatSpec
[error] class Test extends FlatSpec with Matchers {
[error]                        ^
[error] Test.scala:6: not found: type Matchers
[error] class Test extends FlatSpec with Matchers {
[error]                                      ^
[error] Test.scala:8: value should is not a member of String
[error]   "Adding 1 to Array(1)" should "return in Some(2)" in {
[error]                          ^
[error] four errors found

Note that I tried the suggested answer in SBT not finding scalatest for scala 2.10.1 without success.

I also saw the same compile-time errors with:

libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test"

Bill Venners

unread,
Feb 4, 2014, 5:41:23 PM2/4/14
to scalate...@googlegroups.com
Hi Kevin,

I don't see anything wrong with your build file, though you don't need the sonatype resolvers. ScalaTest releases get uploaded to Maven central. That's the one thing that's different from what I normally do, so I might try commenting out the resolvers first, though it doesn't make sense that's the problem. Anyway, when the compiler says scalatest is not a member of org that means it doesn't see the jarfile, as you correctly concluded.

Bill


--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Bill Venners
Artima, Inc.
http://www.artima.com

Seth Tisue

unread,
Feb 4, 2014, 7:36:26 PM2/4/14
to scalate...@googlegroups.com
Pull build.sbt up one level. Inside the `project` folder, any *.sbt files are for building your build (e.g. adding plugins), not for your building your project.

Reply all
Reply to author
Forward
0 new messages