After I created two test case that FlatSpec with DataFrameSuiteBase. But I got errors when do sbt test. I was able to run each of them separately. My test cases does use sqlContext to read files. Here is the exception stack. Judging from the exception, I may need to unregister RpcEndpoint after each test run. info] Exception encountered when attempting to run a suite with class name: MyTestSuit *** ABORTED *** [info] java.lang.IllegalArgumentException: There is already an RpcEndpoint called LocalSchedulerBackendEndpoint [info] at org.apache.spark.rpc.netty.Dispatcher.registerRpcEndpoint(Dispatcher.scala:66) [info] at org.apache.spark.rpc.netty.NettyRpcEnv.setupEndpoint(NettyRpcEnv.scala:129) [info] at org.apache.spark.scheduler.local.LocalSchedulerBackend.start(LocalSchedulerBackend.scala:127) [info] at org.apache.spark.scheduler.TaskSchedulerImpl.start(TaskSchedulerImpl.scala:149) [info] at org.apache.spark.SparkContext.<init>(SparkContext.scala:500)