0
votes

I have a python file which opens up socket connections, which I want to run as a test suite set up. so all the connections needed are open and listening for my test cases to send messages I know we can use Run Process to run a python file ,but how can i achieve the same in the Suite set up but running the file in background and returning the control to RobotFramework

so far what i tried is

*** Settings ***
Documentation  A sample test sutie for robot testsuite
Library   keywordslib/serverlib.py
Library   Process



***Test Cases***


Purchase Transaction

    [Documentation]     A sample test
    purchase transaction

my init.robot file

*** Settings ***
Documentation  A sample ssss test sutie for Mada Transaction
Library  Process

Suite Setup   init


****** keywords ***

init

    Start Process  python   `C:\\Users\\e064070\\IdeaProjects\\RSCATDDFramework\\src\\keywordslib\\MadaTransactionLibrary.py`

The issue what I am facing is the control do not return back to robotframework to execute the test cases

what I expect is to run that python code (serverlib.py) in the setup, and for it to continue to run in the background, while returning the control to Robot Framework to execute the cases

and after execution tear up the process running the back ground

Thanks in advance

1
So, you're asking how to call run process as a setup step? The robot user guide shows how to run keywords as a setup step. What part of that isn't clear? - Bryan Oakley
I'm going out on a limb here with the lack of detials for the intent, but - you probably want to run that python code in the setup, and for it to continue to run in the background, while returning the control to Robot Framework to execute the cases? So it keeps the connections/sockets open, while the cases are running as normal? - Todor Minakov
@TodorMinakov yes correct thats what i want exactly , will edit the question with the details - Abrar Sheik

1 Answers

0
votes

I assume that you have a python file named serverlib.py that has a function named purchase_transaction

def send_purchase_transaction(self)
    result = do_something
    return result

Then in your case you just have to call the python that way:

*** Settings ***
Documentation  A sample test sutie for robot testsuite
Library   keywordslib/serverlib.py
Library   Process

Suite Setup     Run Keywords
...             Purchase Transaction    

*** Keywords ***
Purchase Transaction
    [Documentation]     A sample test
    ${result}  send_purchase_transaction
    log to console  ${result}


***Test Cases***

Your Test Case That Do Something 
    [Documentation]     A sample test

Be sure that the path of the python file is correct. It could be ../keywordslib/serverlib.py or something else like this relative