Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala-方法X不覆盖任何内容_Scala_Apache Spark_Scalatest - Fatal编程技术网

Scala-方法X不覆盖任何内容

Scala-方法X不覆盖任何内容,scala,apache-spark,scalatest,Scala,Apache Spark,Scalatest,我试图在涉及数据流的Spark流应用程序上执行一些单元测试 我发现它在以下方面非常有用:StreamingSuiteBase。它包含一个名为testOperation的方法,您可以向该方法传递输入、要测试的操作和预期的输出。它将验证您的预期输出是否与实际输出匹配 我面临的问题是,在平等性验证期间,我得到的确实是完全相同的对象,但被包装到不同的集合中: 预期:列表(myObject) 实际值:数组(myObject) testOperation的定义如下: def testOperatio

我试图在涉及数据流的Spark流应用程序上执行一些单元测试

我发现它在以下方面非常有用:StreamingSuiteBase。它包含一个名为testOperation的方法,您可以向该方法传递输入、要测试的操作和预期的输出。它将验证您的预期输出是否与实际输出匹配

我面临的问题是,在平等性验证期间,我得到的确实是完全相同的对象,但被包装到不同的集合中:

  • 预期:列表(myObject)
  • 实际值:数组(myObject)
testOperation的定义如下:

  def testOperation[U: ClassTag, V: ClassTag](
      input: Seq[Seq[U]],
      operation: DStream[U] => DStream[V],
      expectedOutput: Seq[Seq[V]],
      ordered: Boolean
    ) (implicit equality: Equality[V]): Unit = {
    val numBatches = input.size

    withOutputAndStreamingContext(setupStreams[U, V](input, operation)) {
      (outputStream, ssc) =>

      val output: Seq[Seq[V]] = runStreams[V](
        outputStream, ssc, numBatches, expectedOutput.size)
      verifyOutput[V](output, expectedOutput, ordered)
    }
  }
这不允许我使用
列表(数组(myObject))

因此,我的第二个选择是修改方法
verifyOutput
。我打算从代码中重写它,只是添加几行来生成列表(数组(myObject))。像这样(更新了):

我做错了什么?

根据,StreamingSuiteBase特性有一个self-type
org.scalatest.Suite
,这意味着您必须同时扩展Suite-type类(在您的情况下是这样),否则它将无法编译

你可以参考:

有关Scala自身类型的更多信息,请参考:

您不需要
V:ClassTag
我看到的基本IDE生成的重写方法是:

override def verifyOutput[V](output: Seq[Seq[V]],
                             expectedOutput: Seq[Seq[V]],
                             ordered: Boolean)
                             (implicit evidence$1: ClassTag[V], equality: Equality[V]): Unit = {
    super.verifyOutput(output, expectedOutput, ordered)
}
根据,StreamingSuiteBase的trait有一个自类型
org.scalatest.Suite
,这意味着您必须同时扩展Suite类型类(在您的情况下是这样),否则它将无法编译

你可以参考:

有关Scala自身类型的更多信息,请参考:

您不需要
V:ClassTag
我看到的基本IDE生成的重写方法是:

override def verifyOutput[V](output: Seq[Seq[V]],
                             expectedOutput: Seq[Seq[V]],
                             ordered: Boolean)
                             (implicit evidence$1: ClassTag[V], equality: Equality[V]): Unit = {
    super.verifyOutput(output, expectedOutput, ordered)
}

您是否扩展了trait StreamingSuiteBase?你能给出你的测试类的定义吗?@AlexeyNovakov我添加了测试类的定义你扩展了trait StreamingSuiteBase吗?你能给出你的测试类的定义吗?@AlexeyNovakov我添加了测试类的定义非常感谢你的回复。我添加了这个(我根据您的建议更新了代码),但我仍然面临相同的错误。使用IDE生成的默认/超级覆盖方法更新了我的答案,希望这会有所帮助。感谢您的新反馈,但仍然存在相同的错误。非常感谢您的回复。我添加了这个(我根据您的建议更新了代码),但我仍然面临相同的错误。使用IDE生成的默认/超级覆盖方法更新了我的答案,希望这会有所帮助。感谢您的新反馈,但仍然存在相同的错误。
override def verifyOutput[V](output: Seq[Seq[V]],
                             expectedOutput: Seq[Seq[V]],
                             ordered: Boolean)
                             (implicit evidence$1: ClassTag[V], equality: Equality[V]): Unit = {
    super.verifyOutput(output, expectedOutput, ordered)
}