databricksazure-databricksscalatest

Getting scalatest to run from databricks


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 {

Solution

  • Needed to use scalatest test structure for 3.0.8 https://www.scalatest.org/scaladoc/3.0.8/org/scalatest/FeatureSpec.html

      <artifactId>scalatest_2.12</artifactId>
      <version>3.0.8</version>
    

    to match the version 3.0.8 included with databricks runtime

    This resolved our errors