代码之家  ›  专栏  ›  技术社区  ›  KnechtRootrecht

不推荐使用来自ConsumerInfo类型的方法getPactFile()

  •  0
  • KnechtRootrecht  · 技术社区  · 7 年前

    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()

    用什么代替?

    提前谢谢你的帮助。

    2 回复  |  直到 7 年前
        1
  •  1
  •   Irwan Hendra    7 年前

    如果您希望使用JUnit作为提供者验证协议,您可以遵循以下步骤:

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

        2
  •  0
  •   KnechtRootrecht    7 年前

    对源代码的研究揭示了答案:

    /**
       * 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
      }