根据
斯卡拉 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
我只是不明白这里有什么问题。
谢谢任何提示。
我认为您必须将此库添加为依赖项才能使用 scala http://www.scalatest.org 运行测试
至少它是我用来使用 Flink 运行测试的库,一切正常,但我使用其他语法而不是 JUnit
过
了一会儿我想通了。
您需要在build.sbt
中放入另一个依赖项
"com.novocode" % "junit-interface" % "0.8" % "test->default"