當我爲了測試利用spark-testing-base
火花檢測基地奇怪校驗失敗
Map("result" -> Array(3, 6, 9, 12, 15, 18, 21, 24, 27, 0)) did not equal Map("result" -> Array(3, 6, 9, 12, 15, 18, 21, 24, 27, 0))
爲一個測試情況下,火花應用執行sbt test
val input: Map[String, Any] = Map("digits" -> Seq(1, 2, 3, 4, 5, 6, 7, 8, 9, 0))
val expectedOutput: Map[String, Any] = Map("result" -> Array(3, 6, 9, 12, 15, 18, 21, 24, 27, 0))
val result = SimpleContext.runTheJOb(session, input)
最小例子可以發現https://github.com/geoHeil/apache-spark-restAPI-example
編輯
w孔測試用例直接
class SimpleTest extends FunSuite with SharedSparkContext with DatasetSuiteBase {
test("SimpleContext should multiply input numbers by 3") {
val session = spark
val input: Map[String, Any] = Map("digits" -> Seq(1, 2, 3, 4, 5, 6, 7, 8, 9, 0))
val expectedOutput: Map[String, Any] = Map("result" -> Array(3, 6, 9, 12, 15, 18, 21, 24, 27, 0))
val result = SimpleContext.runTheJOb(session, input)
assert(expectedOutput === result)
}
}
@LostInOverflow最小的「代碼」已包含在內。但是如果你喜歡整個代碼,我會編輯這個問題。 –
謝謝!你的要點可能會在任何時候失效,這個問題不僅適用於你。 – 2016-11-30 20:47:42