8000 Iterate through data for entire test · Issue #819 · ovh/venom · GitHub
[go: up one dir, main page]

Skip to content

Iterate through data for entire test #819

Open

Description

@joh9347

It seems like we can iterate through data within the step, but we can't do that for entire test case. Is it possible to support looping in test case level?

Also, is it possible to capture the outputs of the step to the vars if we use range?

Activity

  1. 09bassOp commented on Jul 28, 2025

    @09bassOp
    Contributor

    It is possible. Can you elaborate more on the expected behavior? @joh9347

  2. shanestillwell commented on Aug 11, 2025

    @shanestillwell
    Contributor

    Something like this. The range is at the test case level. That way you could group a number of steps for each item in the range array.

    EDIT: It occured to me this example isn't perfect, since it's using exec twice and they could be combined into one step, but if you were using sql in the first step and http in the second, that would be a more accurate example.

    ---
    name: RangeTestCaseExample
    description: >
      Simple example demonstrating the need for range at testcase level.
      Currently this doesn't work but would be very useful for data-driven testing.
    
    vars:
      databases:
        - name: postgres
          port: 5432
          command: "psql --version"
        - name: mysql
          port: 3306
          command: "mysql --version"
        - name: mongodb
          port: 27017
          command: "mongod --version"
    
    testcases:
      # This is what we WANT to be able to do (but currently doesn't work)
      - name: DatabaseConnectionTest
        info: Test connection to {{.value.name}} database
        range: >
          {{.databases}}
        steps:
          - info: Check if {{.value.name}} is installed
            type: exec
            script: "{{.value.command}}"
            assertions:
              - result.systemout ShouldNotBeEmpty
              - result.code ShouldEqual 0
    
          - info: Test {{.value.name}} port availability
            type: exec
            script: "nc -z localhost {{.value.port}} || echo 'Port {{.value.port}} not available'"
            assertions:
              - result.code ShouldEqual 0
    

    This is what we have to do instead (much more verbose and repetitive)

    
      - name: PostgresConnectionTest
        info: Test connection to postgres database
        steps:
          - info: Check if postgres is installed
            type: exec
            script: "psql --version"
            assertions:
              - result.systemout ShouldNotBeEmpty
              - result.code ShouldEqual 0
    
          - info: Test postgres port availability
            type: exec
            script: "nc -z localhost 5432 || echo 'Port 5432 not available'"
            assertions:
              - result.code ShouldEqual 0
    
      - name: MySQLConnectionTest
        info: Test connection to mysql database
        steps:
          - info: Check if mysql is installed
            type: exec
            script: "mysql --version"
            assertions:
              - result.systemout ShouldNotBeEmpty
              - result.code ShouldEqual 0
    
          - info: Test mysql port availability
            type: exec
            script: "nc -z localhost 3306 || echo 'Port 3306 not available'"
            assertions:
              - result.code ShouldEqual 0
    
      - name: MongoDBConnectionTest
        info: Test connection to mongodb database
        steps:
          - info: Check if mongodb is installed
            type: exec
            script: "mongod --version"
            assertions:
              - result.systemout ShouldNotBeEmpty
              - result.code ShouldEqual 0
    
          - info: Test mongodb port availability
            type: exec
            script: "nc -z localhost 27017 || echo 'Port 27017 not available'"
            assertions:
              - result.code ShouldEqual 0
    
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

      0