0

Within robot framework, I can use a for loop in each test case to Start an SSH connection to each host within a list, and then run commands on that host.

But it seems that the ssh setup happens in every test case which takes a considerable amount of time.

Is there some way in which I can make the connection persistent for every test case in a test suite?

Example Code:

*** Settings ***
Variables       sys_variables.py
Resource        ${RESOURCES}/common.robot

*** Test Cases ***
Ping            :FOR    ${HOST}     IN  @{REACHABLE}
                \   SSH to ${HOST} ${USER} ${PASS}
                \   ${result} = Run and Log ${PING_GOOGLE_DNS}
                \   Should Be Equal As Integers  ${result}  0
                \   log  ${result}

This works, but I'd like to not have to run it in every testcase.

1 Answer 1

3

Just put the tests in a single suite and make the connections in the suite setup. The suite setup is executed one time, before the actual test executions.

Consider the following example code:

*** Settings ***
Suite Setup       SuiteSetup

*** Test Cases ***
Test1
    Log    This is the test 1

Test2
    Log    This is the Test 2

*** Keywords ***
SuiteSetup
    Log    This is the single setup

Put your connection cycle inside the SuiteSetup keyword and you're done.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.