Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

Better DSL #51

Description

@sirinath

I believe the current DSL can be improved. E.g.:

class StatefulTest extends TestSuite with State:
  setup:
  - "an empty cart" Cart() as "myCart":
  - "another empty cart" Cart() as "anotherCart":
  where:
    - tabular:
      +
      * | "beachChair" | "sunScreen" | "total":
      -
      "quantity" |  2  |  3  |  5 :
      "price" |  2  |  3  |  5 :
  then:
  - sequentially:
    - "add two items" using "myCart" '{_.add(CartItem("Beach chair", data["beachChair"]["quantity"]))}:
    - parallelly:
       - ....
       - ....
       - sequentially:
         - ....
         - ....
    - "add another three items" '{state["myCart"].add(CartItem("Sunscreen", data["sunScreen"]["quantity"]))}:
  expect:
  - "contains 5 items" '{state["myCart"].totalQuantity == data["total"]["quantity"]} and:
  - "costing" using "myCart" '{_.totalPrice == data["total"]["price"]}:
  lastly:
  - "do some cleanup" using (_.close())

For table tests can they be specified like:

class MaxTest extends TestSuite with Stateless:
  expect:
    - "Max of a and b" '{ Math.max(data["a"], data["b"]) == data["c"] }

  where:
    - tabular:
      +
      | "a" | "b" | "c":
      -
      |  1  |  3  |  3 :
      |  7  |  4  |  7 :
      |  0  |  0  |  0 :

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions