未能在Scala中触发StreamingMultipleProgramsTestBase测试

时间:2018-03-07 15:36:45

标签: apache-flink flink-streaming

根据

Scala的

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

集成测试部分

测试尝试看起来几乎相同

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

我不知道这里有什么问题。

thx任何提示。

2 个答案:

答案 0 :(得分:0)

我认为您必须将此图书馆添加为依赖项,以便使用scala运行您的测试http://www.scalatest.org

至少它是我用来运行我的Flink测试的图书馆,一切正常,但我使用其他语法代替JUnit

答案 1 :(得分:0)

过了一会儿,我发现了。

您需要在build.sbt

中添加另一个依赖项
"com.novocode" % "junit-interface" % "0.8" % "test->default"