Run Pact Provider Test Class in Sequence

530 Views Asked by At

I am using pact-jvm provider spring. I have two different pact(.json) files lets say (order.json and irs.json), i need to run them in sequentially (order followed by irs), but based on alphabetical order the test classes are picked, the irs run first and order runs second. Is there way to call execute the particular test class provider states or define the test class execution order?

1

There are 1 best solutions below

2
Matthew Fellows On

Pact is not a tool for end-to-end testing, in fact, one of Pact's stated objectives is to reduce or in some cases, completely remove the need for E2E testing.

Instead of doing end-to-end testing, we use contract tests to avoid the need to do that. Doing this has a lot of benefits, including the ability to test and release things separately, avoiding the need for managing test environments and data, and reducing coupling/ordering in tests themselves. Furthermore, it should be able to run on your laptop or on a CI build - you don't need to test against a running provider deployed to a real environment.

If you have to run a set of these tests in a particular sequence, you're doing it wrong

Here are some links to help you understand what I mean a bit better:

https://docs.pact.io/consumer/contract_tests_not_functional_tests https://docs.pact.io/faq/#do-i-still-need-end-to-end-tests https://docs.pact.io/getting_started/what_is_pact_good_for

I would also recommend completing one of our workshops, probably https://github.com/DiUS/pact-workshop-jvm.

It takes about 1 hour, but is well worth your time as all of the core concepts are clearly explained.