0

我是 Pact 的新手,我正在尝试使用 pact-python 验证提供者方面的协议,但一些匹配规则被忽略了。

警告:忽略不支持的匹配规则 {"$.num_issues"=>{"matchers"=>[{"match"=>"integer"}], "combine"=>"AND"}, "$.error"=> {"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[0].issue_id"=>{"matchers"=>[{" match"=>"type"}], "combine"=>"AND"}, "$.response[0].msg"=>{"matchers"=>[{"match"=>"type"}] , "combine"=>"AND"}, "$.response[0].similar_fix_found"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND" }, "$.response[1].issue_id"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.response[1].msg"=>{"matchers"=>[{"match"=>"type"}] , "combine"=>"AND"}, "$.response[1].similar_fix_found"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND" }} 用于路径 ['body']

Consumer 是基于 Java 的 API,Provider 是基于 Python 的 API。

                    "body": {
                        "$.num_issues": {
                            "matchers": [
                                {
                                    "match": "integer"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.error": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[0].issue_id": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[0].msg": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[0].similar_fix_found": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[1].issue_id": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[1].msg": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        },
                        "$.response[1].similar_fix_found": {
                            "matchers": [
                                {
                                    "match": "type"
                                }
                            ],
                            "combine": "AND"
                        }
                    }
                }
            }
        }
    ],
    "metadata": {
        "pact-specification": {
            "version": "3.0.0"
        }
    }

手动将协议规范版本更改为 2.0.0 也没有按要求工作。

任何人都可以提出一些建议..?

4

1 回答 1

0

您需要在 Java 消费者测试中明确设置规范版本。

例如,在 JUnit 测试中,您可以这样做:

@PactTestFor(providerName = "pactflow-example-provider-java-kafka", providerType = ProviderType.ASYNCH, pactVersion = PactSpecVersion.V2)

协议文件的匹配器和结构因版本而异,因此仅在之后更改协议中的版本将无济于事。

于 2020-07-15T03:20:49.707 回答