Add optional argument to @State annotation to specify the endpoint's path it's verifying
See original GitHub issueWe have pact verifications in the Provider, where the @State
annotation are named with arbitrary names, trying to specify the pre-conditions. From the State’s name, we cannot determine the endpoint that it’s trying to verify.
It’s true that in the test class we specify the controller containing the endpoints, but in our case, controllers sometimes have several endpoints.
We have things like this in our contract test classes:
@State("There is a registered user")
public void getUserApiState() throws NotFoundException
{
}
The controller is setup with mocked dependencies in a setup
method annotated with @Before
.
When we see that test method, written by someone else, we have no idea which endpoint it’s testing. We can work it around to find the target endpoint but we want to have a quick way to have that information, for instance when we review Pull Requests.
We’d like the @State
annotation accepts also optional arguments where to specify the endpoint, just as documentation. It should look something like this:
@State(name = "There is a registered user", endpoint = "GET /api/v1/user/{userId}")
… or:
@State(name = "There is a registered user", httpMethod = "GET" path = "/api/v1/user/{userId}")
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:12 (6 by maintainers)
Top GitHub Comments
A State is not specific to an interaction though. Multiple interactions can reuse the same State.
This will now log out any comment associated with the provider state