Skip to content

Steps Then Time

Jörg Flade edited this page Jun 24, 2026 · 3 revisions

Then — Timing


Wait for Processing

Then I wait for {int} ms

Pauses execution for the given number of milliseconds before continuing to the next step.

Use this when the backend processes something asynchronously and there is no polling endpoint available. Prefer When — Polling over a fixed wait whenever the endpoint provides an observable completion signal — polling is faster and more robust than sleeping for a worst-case fixed time.

Scenario: Trigger async processing and verify the side effect
  When executing an authorized POST call to "/api/v1/reports/generate"
  Then I ensure that the status code of the response is 202
  And I wait for 3000 ms
  When executing an authorized GET call to "/api/v1/reports/latest"
  Then I ensure that the status code of the response is 200
  And I ensure that the body of the response contains a field "status" with the value "READY"

Scenario: Send a message and wait for delivery
  Given that the body of the request is
    """
    { "to": "user@example.com", "subject": "Hello" }
    """
  When executing an authorized POST call to "/api/v1/notifications" with previously given body
  Then I ensure that the status code of the response is 201
  And I wait for 1000 ms
  When executing an authorized GET call to "/api/v1/notifications/inbox"
  Then I ensure that the status code of the response is 200
  And I ensure that the body of the response contains a field "unreadCount" with the value "1"

Examples: bdd-cucumber-gherkin-lib/src/test/resources/features/performance/performance.feature


Validate Execution Time

Then I ensure that the execution time is less than {long} ms

Asserts that the scenario has executed in less than the given number of milliseconds up to this step. Use this for SLA / performance smoke tests.

Scenario: List endpoint responds within 200 ms
  When executing an authorized GET call to "/api/v1/users"
  Then I ensure that the status code of the response is 200
  And I ensure that the execution time is less than 200 ms

Scenario: Report generation completes within 2 seconds
  When executing an authorized POST call to "/api/v1/reports/generate"
  Then I ensure that the status code of the response is 200
  And I ensure that the execution time is less than 2000 ms

Scenario: Full create-and-fetch flow stays within SLA
  Given that the body of the request is
    """
    { "name": "Quick Resource" }
    """
  When executing an authorized POST call to "/api/v1/resources" with previously given body
  Then I ensure that the status code of the response is 201
  And I store the string of the field "id" in the context "NEW_ID" for later usage
  Given that the request body in the scenario context map has been reset
  When executing an authorized GET call to "/api/v1/resources/${NEW_ID}"
  Then I ensure that the status code of the response is 200
  And I ensure that the execution time is less than 500 ms

Examples: bdd-cucumber-gherkin-lib/src/test/resources/features/performance/

Clone this wiki locally