question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add optional argument to @State annotation to specify the endpoint's path it's verifying

See original GitHub issue

We 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:open
  • Created 3 years ago
  • Reactions:7
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
anto-accommented, Aug 11, 2020

A State is not specific to an interaction though. Multiple interactions can reuse the same State.

0reactions
uglyogcommented, Aug 22, 2020

This will now log out any comment associated with the provider state

12:23:56.094 [Test worker] INFO  a.c.d.p.p.junit.RunStateChanges - Invoking state change method 'an active account exists':SETUP (I'm a comment)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add optional argument to @State annotation to specify the ...
We have pact verifications in the Provider, where the @State annotation are named with arbitrary names, trying to specify the pre-conditions ...
Read more >
How do I use optional parameters in Java? - Stack Overflow
i want to add parameter dependency for that.let's say i want set param3 only if i set param1. For eg. i want to...
Read more >
Writing REST Services with RESTEasy Reactive - Quarkus
Any class annotated with a @Path annotation can have its methods exposed as REST endpoints, provided they have an HTTP method annotation (see ......
Read more >
Using Python Optional Arguments When Defining Functions
In this tutorial, you'll learn about Python optional arguments and how to define functions with default values. You'll also learn how to create...
Read more >
Annotations | Kubernetes
Annotations are key/value pairs. Valid annotation keys have two segments: an optional prefix and name, separated by a slash ( / ). The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found