Closed SchulteMarkus closed 12 months ago
The shuffle you refer to is due to you not providing an example value, so a random one is generated each time. You can provide an actual value to use as the second parameter.
final DslPart body = new PactDslJsonBody()
.integerType("id", 1000)
In my case, it a little bit more complex. Let's say, I am expecting
[{"id":1}{"id":2}]
So, if I set "id" to "1000", both ids will have fixed value "1000", but I need different ones (which should stay constant between HTTP requests to the "Pact-server").
Pact doesn't have any mechanism for keeping things constant between different requests, as this is starting to stray into behavioural testing space. Each request is validated in isolation.
We could look at using a sequence generator for IDs, but subsequent requests will get different IDs.
Now that I think of it, by resetting the sequence for each request, you should then always get the same sequence of IDs
Hmm, in my opinion, within the same JUnit-test, I would expect the Pact-server to answer the same response - just as I would expect it from another service.
Hi there,
in my Pact, I am using (among others) "id" of type integer in the request body.
When doing my requests against the "Pact-server", "id" is shuffled on each request. In my test, I am having some subsequent HTTP-calls to my Pact-endpoint, where I expect the result to be constant (for that test). Is there a way to not shuffle "id" on each request?