如何从契约json文件生成pact使用者的模拟服务器?

时间:2017-10-17 11:51:43

标签: pact pact-java

我想使用提供商的合同文件来针对消费者运行测试。 我有

{
"provider": {
    "name": "Provider"
},
"consumer": {
    "name": "Consumer"
},
"interactions": [
    {
        "description": "Get data",
        "request": {
            "method": "Get",
            "path": "/data/1"
        },
        "response": {
            "status": 200,
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "message": ""
            }
        },
        "providerState": "state"
    }
],
"metadata": {
    "pact-specification": {
        "version": "2.0.0"
    },
    "pact-jvm": {
        "version": "3.5.6"
    }
}

并希望用它来生成pact模拟服务器,如:

RequestResponsePact pact = new RequestResponsePact(mockServerDescriptionString);

是否可以这样做?

1 个答案:

答案 0 :(得分:2)

没有。但您可以使用pact-stub-serverpact-stub-service CLI