Hey Guys, I've come across this below question, ca...
# general
z
Hey Guys, I've come across this below question, can you please provide some insights? Bascially, per my understanding there are two ways to create/run pact tests.. 1. create and run the pact tests just like unit tests i.e mock all the input data as we do in traditional unit tests (no need to spin up the dependencies and no need to create the instance of application) 2. spin up the environment, run the instance of the application along with all the dependencies like database etc and then run the pact tests.. I understand that the major usp of pact is that it provides fast feedback and hence #1 should be relevant. However, I would like to hear your thoughts as well.
m
We've done AMAs on the scope of these tests before: https://docs.pact.io/help#join-an-upcoming-ask-me-anything-ama-session
Are you talking about consumer or provider side here?
Consumer should be closer to a unit test
z
and how about provider side?
m
Provider usually you would start the application locally and stub out dependencies
z
Oh, but why can't the provider tests be closer to a unit test? what if we just mock the function which returns the end result?
m
Can you perhaps elaborate on what exactly you're mocking here?
z
Let's suppose in case of event driven architecture, there is one boundary function which takes some input and generate the output which will then be put in to the queue. I'm mocking the input data to that function. I found this on pact official website, then pact tests are two set of unit tests (one set on consumer side and another one on provider side) Having said that, I'm curious to understand what is the need to start the provider application locally?
đź‘€ 1
m
Thanks for clarifying. So in message Pact, you can definitely get closer to a true unit test.
I asked, because in an HTTP provider test, you usually have several important layers that can be tested - e.g. the controllers, routing etc. and the actual request handlers. Extensive mocking here can be problematic, because the goal is to make sure the provider can both understand and respond correctly.
The answer is “it depends”, basically. If you have really good coverage across various layers of the system where you have confidence in narrowing the scope of a pact test - all power to you
z
Got it. Thank you for explaining it in detail! 🙂
👍 1