0

I have a scenario where my provider service provides 3 functionalities. At consumer end I have 3 different classes to write tests for these 3 functionalities. When pact file is generated, it encompasses all the tests with same consumer-provider combination. so far so good.

When it comes to provider tests, I wish to have a same structure of 3 classes for 3 functionalities. But if I do that and when I run tests from 1st class, PACT also tries to search for other methods as per the pact file and fails cos of other methods not found. How can I handle this scenario.

example:
ConsumerTestClass1
ConsumerTestClass2
ConsumerTestClass3

all define the below pact
@Pact(provider = PROVIDER, consumer = CONSUMER)
public MessagePact createPactForCareerLevelClassifier(MessagePactBuilder builder) {}

Now lets say every class has 3 test methods, so pact file in all will have 9

On provider side I have 3 test classes
ProvdiderTestClass1
ProvdiderTestClass2
ProvdiderTestClass3

ProviderTestClass1 has actual test annotated with @PactVerifyProvider
Now when I run tests for ProviderTestClass1 , PACT complains that it was not able to find any methods matching for 6 other contracts which are actually in ProvdiderTestClass2 and ProvdiderTestClass3 classes

  • 1
    It sounds to me like you're trying to run all pact interactions at the same time, instead of just running the one you need for that specific test. If you can provide more information or potentially a code example/diagram, it would help me figure out what you're trying to accomplish. – J_A_X Jan 25 '17 at 03:51
  • I added an example, see if that helps – Aniket Gadre Jan 25 '17 at 05:50

1 Answers1

0

It sounds like you're not specifying to @PactVerifyProvider state, hence it's running all of them.

You should refer to this example where you can clearly see that the state is being set via the parameter like so @PactVerifyProvider('an order confirmation message') which will only verify for Pact interactions of the same description.

J_A_X
  • 12,857
  • 1
  • 25
  • 31