I am new to PACT and trying to use pact-net for contract testing for a .net microservice. I understand the concept of consumer test which generates a pact file. There is the concept of a provider state middleware which is responsible for making sure that the provider's state matches the Given() condition in the generated pact. I am bit confused on the following or how to achieve this:
The provider tests are run against the actual service. So we start the provider service before tests are run. My provider service interacts with a database to store and retrieve records. PACT also mentions that all the dependencies of a service should be stubbed.
- So we run the actual provider api that is running against the actual db?
- If we running the api against actual db how do we inject the data into the db? Should we be using the provider api's own endpoints to add the Given() data?
- If the above is not the correct approach then what is?
All the basic blog articles I have come across do not explain this and usually have examples with no provider states or states that are just some text files on the file system.
Help appreciated.