happy Friday everyone! We’re very excited to set u...
# general
m
happy Friday everyone! We’re very excited to set up Pact tests in our company. We have already everything in a place but we’re still unsure with this functional vs contract tests thing. I’m looking for an advise if we should have just one or multiple interactions for an endpoint. The endpoint GET
/profile
expects a query parameter
code
and returns a user profile object. User can be in one of three statuses:
new
,
lead
, and
user
. When it’s
new
, the profile must have
emailAddress
property. If it’s
lead
or
user
there must be also
phoneNumber
and
username
properties present in the response. There are also optional fields like
firstName
that might be null or a string. Now, the questions are: 1. Should we have only one interaction for all the user statuses or an interaction for each status separately (wouldn’t it be testing a business logic?) 2. Should we have a separate interaction for the optional properties to be given (not null)? I hope that’s a good place for such questions, Best regards
👋 1
b
Good philosophical question, and, in the end, not actually a Pact question :) You can go either way on all the aspects you've mentioned, but you'll be trading-off specificity.
Personally, I'd have a state for each combo, so if something breaks, I know exactly which bit isn't working. That'll require anywhere from 2 to 6 states for the happy paths. That granularity is a problem for some people, but I prefer to have many small detangled bits to maintain.