【问题标题】:Failing to trigger StreamingMultipleProgramsTestBase Test in Scala未能在 Scala 中触发 StreamingMultipleProgramsTestBase 测试
【发布时间】:2018-03-07 15:36:45
【问题描述】:

根据

https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/stream/testing.html 用于 Scala

集成测试部分

测试尝试看起来几乎相同

import java.util
import java.lang.Long
import com.google.common.collect.Lists
import org.apache.flink.streaming.api.functions.sink.SinkFunction
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.streaming.util.StreamingMultipleProgramsTestBase
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.junit.Test
import org.junit.Assert.assertEquals



class HotelSearchIntegrationTest extends StreamingMultipleProgramsTestBase{

  @Test
  def testMatching(): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)


    env
      .fromElements(1L)
      .map( v => v).addSink( v => println(s"v"))

    // execute
    env.execute()

    assertEquals(1L, 1L)

  }

}

sbt test 没有给我带来任何执行测试

[info] Compiling 1 Scala source to         .../target/scala-2.11/test-classes...
[info] Run completed in 10 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[success] Total time: 1 s, completed Mar 7, 2018 4:30:45 PM

我只是不明白这里出了什么问题。

感谢任何提示。

【问题讨论】:

    标签: apache-flink flink-streaming


    【解决方案1】:

    我认为您必须将此库添加为依赖项才能使用 scala http://www.scalatest.org 运行测试

    至少它是我用来使用 Flink 运行测试的库,并且一切正常,但我使用的是其他语法而不是 JUnit

    【讨论】:

      【解决方案2】:

      过了一会儿,我想通了。

      您需要在 build.sbt 中添加另一个依赖项

      "com.novocode" % "junit-interface" % "0.8" % "test->default"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-01-20
        • 2019-12-17
        • 2021-07-06
        • 1970-01-01
        • 2013-04-11
        • 1970-01-01
        相关资源
        最近更新 更多