MaibornWolff / alt-core-js

Acceptance & Load testing framework
https://www.npmjs.com/package/@maibornwolff/alt-core-js
MIT License
7 stars 1 forks source link

Support initial setting of variables with javascript #42

Closed johannesloher closed 5 years ago

johannesloher commented 5 years ago

As a tester writing tests with ALT, I want to be able to specify the values for parameters using javascript so that I can use dynamic data in addition to static data.

Currently it is only possible to set parameters (in path, form, json body) to static values or to some value generated by a previous action. There are some cases where it would be nice to be able to use dynamically generated data that does not depend on a previous action, e.g. using the current date, generating random values and similar things. This can be worked around by using a previous action and setting the variable there, but this is a hacky workaround.

Some possible solutions:

  1. Allow inline javascript in the definition of parameters, which is executed and the parameter is set to the result. This could look something like
    type: REST
    service: name-of-the-service
    endpoint: /some/endpoint
    method: POST
    headers:
    Content-Type: application/json
    data:
    var1: "{{(new Date()).toISOString()}}"
  2. Allow setting variables without requiring an action. This could look something like this:
    
    # my-action.yaml
    type: REST
    service: name-of-the-service
    endpoint: /some/endpoint
    method: POST
    headers:
    Content-Type: application/json

s1-my-scenario.yaml

description: "some description" variables: date: "(new Date()).toISOString()"

actions:

I believe the first of the two options is a lot more user friendly, but it might be more difficult to implement.

bboron86 commented 5 years ago

@johannesloher it's already possible ;) just not documented yet....

<<< new Date().toIsoString() >>>

johannesloher commented 5 years ago

already implemented