Add support for expressions

Description

Add support for a mechanism of expressions which is a functional analogue to transform or generate data:

Expression syntax: #{expression(<arg1>, <arg2>, ..., <argN>)}

  • number of arguments will depend on actual expressions

1) When testing REST API with some endpoints requiring Base64 encoding, following the usual approach one would need to double all steps executing API requests: set of steps accepting String data and another set of steps doing Base64 encoding. It would be more concise to create a one set of steps like "When I send '$data' to '$destination'" and an expression. By doing this we can end up with a widely reusable expression and step: "When I send '#{encodeToBase64(Hello World!)}’ to ‘/some/endpoint’"

2) Instead of hardcoding test data in stories we can create expressions to generate that data, e.g.

  • #{currentDate()} - to generate current date

  • #{randomUUID()} - to generate random UUID
    etc.

3) It might be useful to have expressions for string manipulation, for example if we have data stored in examples table and we want that data to be typed somewhere in different forms, e.g.

  • #{toLowerCase(boB maN)} - produces "bob man"

  • #{toUpperCase(bob man)} - produces "BOB MAN"

  • #{capitalize(bob man)} - produces "Bob Man"
    etc.}}

Activity

Show:

Uladzislau Arlouski March 9, 2020 at 7:12 AM

Hi ,

I will create PR once I have time and then ping you

Thanks

Mauro Talevi March 7, 2020 at 3:22 PM

Hi Uladzislau,

the feature seems rather interesting. Could you please provide a PR with a proof-of-concept implementation?

Thanks

Uladzislau Arlouski February 28, 2020 at 9:36 AM

Hi , could you please take a look at the description above and give your feedback?

Thanks,

Ulad

Uladzislau Arlouski January 31, 2020 at 3:10 PM

Hi , could you please take a look at the description above and give your feedback?

Thanks,

Ulad

Details

Assignee

Reporter

Labels

Fix versions

Priority

Created January 31, 2020 at 3:10 PM
Updated September 23, 2023 at 5:00 PM