原文链接 : http://spark.apache.org/docs/latest/programming-guide.html#unit-testing
译文链接 : http://www.apache.wiki/pages/viewpage.action?pageId=2883720
贡献者 : 多啦a梦,那伊抹微笑
Spark 可以友好的使用流行的单元测试框架进行单元测试。在将 master URL 设置为 local 来测试时会简单的创建一个 SparkContext,运行您的操作,然后调用 SparkContext.stop() 将该作业停止。因为 Spark 不支持在同一个程序中并行的运行两个 contexts,所以需要确保使用 finally 块或者测试框架的 tearDown 方法将 context 停止。
SparkContext
SparkContext.stop()
finally
tearDown