Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better DSL #51

Open
sirinath opened this issue Oct 27, 2020 · 0 comments
Open

Better DSL #51

sirinath opened this issue Oct 27, 2020 · 0 comments

Comments

@sirinath
Copy link

sirinath commented Oct 27, 2020

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 :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant