不推荐使用 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());
它们导致消息:
The method getPactFile() from the type ConsumerInfo is deprecated
用什么代替?
提前感谢您的帮助。
查看源代码揭示了答案:
/**
* 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
}
如果您希望使用 JUnit 将 PACT 验证为提供者,则可以改用以下方法:
https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit
我从这个例子中得到了以下两行: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());
它们导致消息:
The method getPactFile() from the type ConsumerInfo is deprecated
用什么代替?
提前感谢您的帮助。
查看源代码揭示了答案:
/**
* 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
}
如果您希望使用 JUnit 将 PACT 验证为提供者,则可以改用以下方法:
https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit