I am trying to import spark.implicits._ Apparently, this is an object inside a class in scala. when i import it in a method like so:
def f() = {
  val spark = SparkSession()....
  import spark.implicits._
}
It works fine, however i am writing a test class and i want to make this import available for all tests I have tried:
class SomeSpec extends FlatSpec with BeforeAndAfter {
  var spark:SparkSession = _
  //This won't compile
  import spark.implicits._
  before {
    spark = SparkSession()....
    //This won't either
    import spark.implicits._
  }
  "a test" should "run" in {
    //Even this won't compile (although it already looks bad here)
    import spark.implicits._
    //This was the only way i could make it work
    val spark = this.spark
    import spark.implicits._
  }
}
Not only does this look bad, i don't want to do it for every test What is the "correct" way of doing it?