Scala 为什么我的Wiremock没有在测试中启动

Scala 为什么我的Wiremock没有在测试中启动,scala,wiremock,Scala,Wiremock,我的wiremock特点如下: trait WiremockSetup extends BeforeAndAfterAll { self: Suite => import WireMockConfiguration._ protected val wiremockServer = new WireMockServer(options().dynamicPort()) override protected def beforeAll(): Unit = { supe

我的wiremock特点如下:

trait WiremockSetup extends BeforeAndAfterAll { self: Suite =>

  import WireMockConfiguration._

  protected val wiremockServer = new WireMockServer(options().dynamicPort())

  override protected def beforeAll(): Unit = {
    super.beforeAll()
    wiremockServer.start()
  }

  override protected def afterAll(): Unit = {
    wiremockServer.stop()
    super.afterAll()
  }

}
An exception or error caused a run to abort. 
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.github.tomakehurst.wiremock.jetty9.JettyHttpServerFactory.buildHttpServer(JettyHttpServerFactory.java:63)
    at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:76)

我在我的测试课上混合了这种特质

class Foo extends FlatSpec with WiremockSetup{

"Test scneario" should "do something" in {
assert (1 == 1)
}

}

但我发现编译问题如下:

trait WiremockSetup extends BeforeAndAfterAll { self: Suite =>

  import WireMockConfiguration._

  protected val wiremockServer = new WireMockServer(options().dynamicPort())

  override protected def beforeAll(): Unit = {
    super.beforeAll()
    wiremockServer.start()
  }

  override protected def afterAll(): Unit = {
    wiremockServer.stop()
    super.afterAll()
  }

}
An exception or error caused a run to abort. 
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.github.tomakehurst.wiremock.jetty9.JettyHttpServerFactory.buildHttpServer(JettyHttpServerFactory.java:63)
    at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:76)

异常或错误导致运行中止。
java.lang.reflect.InvocationTargetException
位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
位于java.lang.reflect.Constructor.newInstance(Constructor.java:423)
位于com.github.tomakehurst.wiremock.jetty9.jettyhtpserverfactory.buildHttpServer(jettyhtpserverfactory.java:63)
位于com.github.tomakehurst.wiremock.WireMockServer。(WireMockServer.java:76)

为什么会出现问题?

请确保您具有此依赖关系:

"com.github.tomakehurst"  %  "wiremock-jre8"            % "2.22.0" 

确保您具有此依赖项:

"com.github.tomakehurst"  %  "wiremock-jre8"            % "2.22.0"