PACT-Test 中的日期格式被忽略并失败(Java 17)

问题描述 投票:0回答:1

我们遇到一个问题,迁移后某些 Pact 测试失败。看来测试忽略了合同日期的匹配规则。

匹配规则:

          "$.entity.month": {
            "matchers": [
              {
                "match": "date",
                "format": "yyyy-MM"
              }
            ],

Pact 的 Maven 依赖:

        <dependency>
            <groupId>au.com.dius.pact</groupId>
            <artifactId>consumer</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>au.com.dius.pact.consumer</groupId>
            <artifactId>java8</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>au.com.dius.pact.consumer</groupId>
            <artifactId>junit5</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>au.com.dius.pact.provider</groupId>
            <artifactId>junit5</artifactId>
            <version>4.1.24</version>
            <scope>test</scope>
        </dependency>

测试的事件有一个格式为“yyyy-mm”的字段。但是,我得到以下输出:

    1.1) body: $.entity.month Expected "2023-02" to match a date of 'yyyy-MM-dd': Unable to parse the date: 2023-02

似乎匹配器的“格式”字段被忽略,测试需要标准格式的日期。

我尝试过更改协议提供者和消费者的版本。但这根本没有帮助。会不会是Java版本的问题?

预期行为:测试为绿色。

kotlin pact matcher
1个回答
0
投票

我将版本更改为4.1.41后问题解决了。

© www.soinside.com 2019 - 2024. All rights reserved.