Package au.com.dius.pact.consumer.junit
Class PactProviderRule
java.lang.Object
org.junit.rules.ExternalResource
au.com.dius.pact.consumer.junit.BaseProviderRule
au.com.dius.pact.consumer.junit.PactProviderRule
- All Implemented Interfaces:
org.junit.rules.TestRule
A junit rule that wraps every test annotated with
PactVerification.
Before each test, a mock server will be setup at given port/host that will provide mocked responses for the given
provider. After each test, it will be teared down.
If no host is given, it will default to 127.0.0.1. If no port is given, it will default to a random port.
If you need to use HTTPS, use PactHttpsProviderRule-
Field Summary
Fields inherited from class au.com.dius.pact.consumer.junit.BaseProviderRule
config, provider, target -
Constructor Summary
ConstructorsConstructorDescriptionPactProviderRule(String provider, au.com.dius.pact.core.model.PactSpecVersion pactSpecVersion, Object target) Creates a mock provider by the given name.PactProviderRule(String provider, Object target) Creates a mock provider by the given name.PactProviderRule(String provider, String hostInterface, Integer port, au.com.dius.pact.core.model.PactSpecVersion pactVersion, Object target) Creates a mock provider by the given namePactProviderRule(String provider, String hostInterface, Integer port, Object target) Creates a mock provider by the given name -
Method Summary
Methods inherited from class au.com.dius.pact.consumer.junit.BaseProviderRule
apply, getConfig, getMockServer, getPacts, getPort, getUrl, validateResultMethods inherited from class org.junit.rules.ExternalResource
after, before
-
Constructor Details
-
PactProviderRule
public PactProviderRule(String provider, String hostInterface, Integer port, au.com.dius.pact.core.model.PactSpecVersion pactVersion, Object target) Creates a mock provider by the given name- Parameters:
provider- Provider name to mockhostInterface- Host interface to bind to. Defaults to 127.0.0.1port- Port to bind to. Defaults to zero, which will bind to a random port.pactVersion- Pact specification versiontarget- Target test to apply this rule to.
-
PactProviderRule
Creates a mock provider by the given name- Parameters:
provider- Provider name to mockhostInterface- Host interface to bind to. Defaults to 127.0.0.1port- Port to bind to. Defaults to a random port.target- Target test to apply this rule to.
-
PactProviderRule
Creates a mock provider by the given name. Binds to localhost and a random port.- Parameters:
provider- Provider name to mocktarget- Target test to apply this rule to.
-
PactProviderRule
public PactProviderRule(String provider, au.com.dius.pact.core.model.PactSpecVersion pactSpecVersion, Object target) Creates a mock provider by the given name. Binds to localhost and a random port.- Parameters:
provider- Provider name to mocktarget- Target test to apply this rule to.
-