Getting scalatest to run from databricks

Viewed 39

What's missing in order to get this simple scalatest working in databricks? (mostly as per their userguide)

  1. I have cluster, into which I've uploaded the following latest scalatest jar and restarted cluster: https://oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.13/3.2.13/scalatest_2.13-3.2.13.jar

  2. Following: https://www.scalatest.org/user_guide/using_the_scalatest_shell I'm running their sample code:

import org.scalatest._

class ArithmeticSuite extends AnyFunSuite with matchers.should.Matchers {
   test("addition works") { 
     1 + 1 should equal (2)
   } 
} 
run(new ArithmeticSuite)

screenshot of code as the above isn't formatting properly here

The errors start with:

command-1362189841383727:3: error: not found: type AnyFunSuite
class ArithmeticSuite extends AnyFunSuite with matchers.should.Matchers {
                              ^
command-1362189841383727:3: error: object should is not a member of package org.scalatest.matchers
class ArithmeticSuite extends AnyFunSuite with matchers.should.Matchers {
2 Answers

Databricks clusters are using Scala 2.12, while you have installed library compiled for Scala 2.13 that is binary incompatible with Databricks cluster. Take version for Scala 2.12 (with _2.12 suffix).

P.S. Although scalatest already could be a part of Databricks Runtime - check it by running %sh ls -ls /dataricks/jars/*scalatest*

Related