Search code examples
pact

Exactly one pact source should be set


I am writing pact testing for provider. I have written a class. While running as JUNIT , i am getting exception, "Exactly one pact source should be set"" Could you please help ?

this is my code..

@RunWith(SpringRestPactRunner.class)
@Provider("personlisation-service")
@PactFolder("/pacts")
@PactUrl(urls = {"file:///pacts/PersonalisationServiceContractTest-CourierProfileController.json"})
@IgnoreNoPactsToVerify
@PactBroker(host = "${pact.broker.host:pact.hermescloud.co.uk}",
            port = "${pact.broker.port:443}",
            protocol = "${pact.broker.protocol:https}",
            tags = "${pactbroker.tags:master}")
@SpringBootTest(
        classes = Application.class,
        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
        properties = {.....
 }
      )

public class CourierProfilePactProviderTestIT {
--------
.
..
....

}

Solution

  • Looks like you've specified both @PactBroker and @PactUrl. Both of these are flags to tell the framework where to fetch pacts from. You should use just one of these (probably the broker in most cases)