繁体   English   中英

不赞成使用ConsumerInfo类型的getPactFile()方法

[英]The method getPactFile() from the type ConsumerInfo is deprecated

我从此示例中获得了以下两行: https : //github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider

consumer.setPactFile(new File("target/pacts/ping_client-ping_service.json"));
testConsumerPact = (Pact) PactReader.loadPact(consumer.getPactFile());

它们导致消息:

不赞成使用ConsumerInfo类型的getPactFile()方法

用什么代替呢?

感谢您的帮助。

如果希望使用JUnit将PACT验证为提供者,则可以改用以下方法:

https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit

查看源代码可以发现答案:

/**
   * Sets the Pact File for the consumer
   * @param file Pact file, either as a string or a PactSource
   * @deprecated Use setPactSource instead
   */
  @Deprecated
  void setPactFile(def file) {
    if (file instanceof PactSource) {
      pactSource = file
    } else {
      pactSource = new FileSource(file as File)
    }
  }

  /**
   * Returns the Pact file for the consumer
   * @deprecated Use getPactSource instead
   */
  @Deprecated
  def getPactFile() {
    pactSource
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM