Ivan Mikhalka
02/13/2023, 2:37 PMpact-gradle-plugin .
What I want to achieve - two separate gradle tasks for running provider test a) using contracts fetched from broker;
b) using contract file on local file system.
For now I have one for pact broker:
pact {
broker {
pactBrokerUrl = 'url'
pactBrokerToken = 'token'
}
serviceProviders {
MyProvider {
....
fromPactBroker {
withSelectors {
// Some selectors
}
}
}
}
}
I’ve tried:
1. Add another provider MyProviderLocal under serviceProviders with specifying path to local pact file
2. Add new gradle task and put inside pact dsl:
task pactLocal {
pact {
......
}
}
Both attempts not working, it recognise broker block and always trying to get pacts from broker.uglyog
pact block is global and not task specific. There are two ways you can do it, if you want to have two different verification tasks, you can use different provider names (MyProvider and MyProviderLocal), or if you want only a single provider name, you can setup two different sources and they will both be verified as part of the same task.Ivan Mikhalka
02/14/2023, 7:45 AMserviceProviders doesn’t work - as broker block defined at top level, plugin tries to find provider named MyProviderLocal directly in broker, and of course, it not exists.
I want to run single option - broker or local contracts, so, do not suppose to have two sources at one place.Ivan Mikhalka
02/14/2023, 7:49 AMCaused by: <http://au.com|au.com>.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path '<https://secretescapes.pactflow.io/pacts/provider/MyProviderLocal/for-verification>'Ivan Mikhalka
02/14/2023, 7:56 AMbroker block on the fly in command line, not in build.gradle directly, it could resolve my issue.
Seems like presence of broker block orders to search for all providers in brokerIvan Mikhalka
02/14/2023, 7:58 AM4.1.39 version of <http://au.com|au.com>.dius.pact due to version limitations of Gradle and Javauglyog
Ivan Mikhalka
02/14/2023, 9:21 AMIvan Mikhalka
02/14/2023, 9:37 AMif(useBroker="true") {
broker {
....
}
}
And then run ./graldew pactVerify_FlashsalesLocal -PuseBroker=false