https://linen.dev logo
#general
Title
# general
n

Nuno Frias

03/01/2024, 11:10 AM
Hi all I don't know if this is the proper channel to report a bug or clarify the actual behaviour, but here I go: When using scenarios I am verifying that the scenario with
"requiredScenarioState": "Started"
is being skipped, and instead Wiremock is executing the next stub. Going through the docs I don't believe that is the expected behaviour. I am using the image
wiremock:3.4.2-1
t

Tom

03/01/2024, 11:26 AM
I suggest posting your full stub details and the details of the requests you’re making here, then we can determine whether it’s a bug or configuration problem. If it’s a bug we’ll move it over to GH issues.
n

Nuno Frias

03/01/2024, 11:30 AM
Here is my stub:
Copy code
{
  "mappings": [
    {
      "scenarioName": "My test scenario",
      "requiredScenarioState": "Started",
      "request": {
        "method": "GET",
        "urlPattern": "/example"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "stepNumer": 0
        }
      }
    },
    {
      "scenarioName": "My test scenario",
      "requiredScenarioState": "Started",
      "newScenarioState": "Step1",
      "request": {
        "method": "GET",
        "urlPattern": "/example"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "stepNumer": 1
        }
      }
    },
    {
      "scenarioName": "My test scenario",
      "requiredScenarioState": "Step1",
      "newScenarioState": "Step2",
      "request": {
        "method": "GET",
        "urlPattern": "/example"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "stepNumer": 2
        }
      }
    },
    {
      "scenarioName": "My test scenario",
      "requiredScenarioState": "Step2",
      "newScenarioState": "Step3",
      "request": {
        "method": "GET",
        "urlPattern": "/example"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "stepNumer": 3
        }
      }
    },
    {
      "scenarioName": "My test scenario",
      "requiredScenarioState": "Step3",
      "newScenarioState": "Step4",
      "request": {
        "method": "GET",
        "urlPattern": "/example"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "stepNumer": 4
        }
      }
    }
  ]
}
When I send my requests I get:
Copy code
$ curl <http://localhost:11091/example>
{"stepNumer":1}

$ curl <http://localhost:11091/example>
{"stepNumer":2}

$ curl <http://localhost:11091/example>
{"stepNumer":3}

$ curl <http://localhost:11091/example>
{"stepNumer":4}
I would expect the first request to return
"stepNumer":0
I was roughly following the example on https://wiremock.org/docs/stateful-behaviour/
t

Tom

03/01/2024, 11:31 AM
You have 2 stubs with the same method/URL and required state, so I think you need to get rid of one of them
n

Nuno Frias

03/01/2024, 11:32 AM
So the first stub can have a
"newScenarioState"
?
t

Tom

03/01/2024, 11:33 AM
I would suggest ditching the first one and keeping the rest as-is
n

Nuno Frias

03/01/2024, 11:34 AM
That works as intended.
👍 1
I though the very first state could not have "newScenarioState" as per the example in the docs.
Thank you 🙌
t

Tom

03/01/2024, 11:35 AM
Sounds like we need to review that bit of documentation
newScenarioState
is optional, but there’s never a case where you can’t have it
👍 1