2

I am trying to create a loop in PyRestTest, this is my code:

# Login
- test:
  - group: 'Login'
  - name: 'Test login post'
  - url: {template: 'api/login/'}
  - method: 'POST'
  - body: {template:'{"username":"$username",
                      "email":"$username",
                      "password":"$password"}'}
  - headers: {Content-Type: application/json}
  - extract_binds:
    - 'token': {'jsonpath_mini': "key"}

# Logout
- test:
  - group: 'Logout'
  - name: 'Test logout post'
  - url: {template: 'api/logout/'}
  - method: 'POST'
  - headers: {Content-Type: application/json}

How can I execute this code over and over?. I am expecting something like:

loop(10):
    # Login
    ...
    # Logout
    ...

In order to execute 10 times these tests. Is it possible?

0 Answers0