简体   繁体   中英

Scalatest + maven

I am trying to use scalatest to test a class. This is the test I am trying to run:

    @RunWith(classOf[JUnitRunner])
class CategorizationSpec extends FlatSpec with BeforeAndAfter with Matchers{
  var ss:SparkSession = _
  before{
    System.setProperty("hadoop.home.dir", "/opt/spark-2.0.0-bin-hadoop2.7");
    val conf = new SparkConf(true)
      .set("spark.cassandra.connection.host","localhost")
      .set("spark.sql.crossJoin.enabled","true")
      .set("spark.executor.memory","4g")
    Logger.getLogger("org").setLevel(Level.OFF)
    Logger.getLogger("akka").setLevel(Level.OFF)
    ss =  SparkSession
      .builder()
      .master("local")
      .appName("categorization")
      .config(conf)
      .getOrCreate()
    ss.conf.set("spark.cassandra.connection.host","localhost")


  }

  "DictionaryPerUser" should "be empty" in {
    val dpuc=new DictionaryPerUserController(ss)
    dpuc.truncate()
    dpuc.getDictionary shouldBe null
  }
}

but I get the following error:

[ERROR] /path/project/datasystem/CategorizationSpec.scala:3: error: object controllers is not a member of package path.project.datasystem [ERROR] import path.project.datasystem.controllers.DictionaryPerUserController

But I have that class in /src/main/scala/path/project and the test class is in /src/test/scala/path/project

Do you know any idea?

(Posted solution on behalf of the OP) .

Solved, sorry it was a problem in my pom!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM