Reputation: 49
here's my robot code
Database-Keywords-Test
connect to database using custom params cx_Oracle ${DB_CONNECT_STRING}
${queryResults}= Query Select * from QA_USER.SealTest_Security_A order by SECURITY_ID
Log ${queryResults}
${queryResults1}= Query Select * from QA_USER.SealTest_Security_B order by SECURITY_ID
Log ${queryResults1}
Upvotes: 1
Views: 3301
Reputation: 864
The Robot Framework is written in Python, which makes for a number of good entry points.
You have to make a design decision (or determine the design decision already made by your team) around which to use.
Robot native solution
If the results from the two tables in your system are meant to be identical, you might be able to just use a built-in Robot framework keyword directly and not call out to Python at all.
*** Settings ***
Documentation Exercise database keywords (Robot-only).
Library Collections
Library # <Database library implied above>
*** Test Cases ***
User Settings Test
[Documentation] User details db comparison (Database-Keywords-Test)
${queryResultsA}= Query Select * from QA_USER.SealTest_Security_A order by SECURITY_ID
${queryResultsB}= Query Select * from QA_USER.SealTest_Security_B order by SECURITY_ID
Lists Should Be Equal ${queryResultsA} ${queryResultsB}
Robot invoking Python solution
If you want Robot to drive Python, ie you invoke robot as the main entry point, you can import Python modules using the Library keyword.
Robot test case:
*** Settings ***
Documentation Exercise database keywords (call out to Python).
Library userManagement
Library # <Database library implied above>
*** Test Cases ***
User Settings Test
[Documentation] User details db comparison (Database-Keywords-Test)
${queryResultsA}= Query Select * from QA_USER.SealTest_Security_A order by SECURITY_ID
${queryResultsB}= Query Select * from QA_USER.SealTest_Security_B order by SECURITY_ID
${diff} = Compare Users ${userResultsA} ${userResultsB}
Should Be Empty ${diff}
Python library userManagement.py:
class UserManagement:
ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
def compareUsers(self,userResultsA,userResultsB):
# diff implementation depends on the structure of user results
# which are not shared in the question, but will be related to the
# database library you are using, perhaps a list of
# rows or dictionaries
...
return diff
Python invoking Robot solution
If you want python to drive Robot, you can access the API from Python https://robot-framework.readthedocs.io/en/latest/
The above are some directly related stubs that hopefully let you see the mapping and get off the ground. Using that starting point, I suggest working through the documentation links carefully for next steps.
Upvotes: 1