gpt4 book ai didi

python - 如何使用 python 比较机器人框架的数据输出

转载 作者:行者123 更新时间:2023-12-01 08:28:25 26 4
gpt4 key购买 nike

这是我的机器人代码

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}

最佳答案

机器人框架是用 Python 编写的,这提供了许多很好的入口点。

您必须做出要使用的设计决策(或确定您的团队已经做出的设计决策)。

机器人原生解决方案

如果系统中两个表的结果是相同的,您也许可以直接使用内置的 Robot 框架关键字,而根本不调用 Python。

*** 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}

机器人调用Python解决方案

如果您希望Robot驱动Python,即调用robot作为主要入口点,您可以使用Library关键字导入Python模块。

机器人测试用例:

*** 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 库 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

http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-library-class-or-module

Python调用Robot解决方案

如果你想让Python驱动Robot,你可以从Python访问API https://robot-framework.readthedocs.io/en/latest/

上面是一些直接相关的 stub ,希望能让您看到映射并开始工作。使用这个起点,我建议仔细阅读文档链接以进行后续步骤。

关于python - 如何使用 python 比较机器人框架的数据输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54068251/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com