ovh / venom

🐍 Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Apache License 2.0
1.03k stars 141 forks source link

Skip a step in range/loop doesn't work #651

Open aabouzaid opened 1 year ago

aabouzaid commented 1 year ago

Hi :wave:

Thanks for this nice test suite, it's pretty useful. I use Venom in Camunda Platform Helm charts integration tests.

Use case: I want to control the loop steps conditionally in case some services are not available for testing. So some of the loop items work, and some are skipped.

The problem: It looks like the loop vars are not accessible in skip part.

Example:

testcases:
- name: TEST
  steps:
  - name: "{{ .value.component }}"
    type: http
    range:
    - component: A
      url: http://service-a/health
      skip: 1
    - component: B
      url: http://service-b/health
      skip: 1
    - component: C
      url: http://service-c/health
      skip: 0
    method: GET
    url: "{{ .value.url }}"
    retry: 3
    delay: 10
    skip:
    - "{{ .value.skip }} ShouldNotEqual 1"
    assertions:
    - result.statuscode ShouldEqual 200

I get the following:

• A (range=0) FAIL
 assertion not supported
• B (range=1) FAIL
 assertion not supported
• C (range=2) FAIL
 assertion not supported

The same behaviour would be if I used {{ .index }}, the loop vars are not accessible.

Info:

fokion commented 1 year ago

One of the issues is that you cannot have the assertion wrapped in a string - "{{ .value.skip }} ShouldNotEqual 1" you need to unwrap it. Now having this will make venom fail as it wont be able to parse the file - {{ .value.skip }} ShouldNotEqual 1 so you can convert it to - value.skip ShouldNotEqual 1 . Will try this test case with the a draft pr that I have here #685