【问题标题】:rest webservice testing through robotframework tool通过机器人框架工具进行REST Web服务测试
【发布时间】:2018-05-23 02:52:24
【问题描述】:

我是机器人框架的新手,并且正在通过机器人框架进行 REST Web 服务测试自动化。 我的经理建议我通过机器人框架自动化 SOAPUI,我找到了一个库,即使下面给出的这个库似乎也没有很好的文档记录。 甚至库中给出的示例也更具体到基于 SOAP 的 Web 服务,我正在寻找通过 soapui 自动化而不是基于 soap 的 Web 服务进行的其余 Web 服务测试。 https://github.com/pavlobaron/robotframework-soapuilibrary

所以请建议我通过机器人框架中的 SOAPUI 自动化进行 REST Web 服务测试自动化。

另一种方法是通过没有soapui工具的robotframework进行rest webservice测试自动化。ssome welll文档库可用 http://peritus.github.io/robotframework-httplibrary/HttpLibrary.html

任何人都可以向我推荐以上两个关于用于休息网络服务的机器人框架测试自动化的解决方案。

【问题讨论】:

    标签: web-services rest robotframework


    【解决方案1】:

    要测试 RESTful 服务,您可以使用 Requests 库。这个库的主页是https://github.com/bulkan/robotframework-requests/

    要测试 SOAP 服务,您可以使用 Suds 库。这个库的主页是https://github.com/ombre42/robotframework-sudslibrary

    robotframework 主页上提供了这两个链接以及许多其他链接。这是一个快速链接:

    http://robotframework.org/#test-libraries

    这是一个连接到 RESTful 服务并验证它是否返回状态码 200 以及 JSON 数据具有一些特定键的示例(请注意,此测试在我编写它时通过了,但如果从我写到你读到这里,API 发生了变化,它可能会失败)

    *** Settings ***
    | Library | RequestsLibrary
    | Library | Collections
    
    *** Variables ***
    | ${SERVICE_ROOT} | http://api.openweathermap.org
    | ${SERVICE_NAME} | openweathermap
    
    *** Test Cases ***
    | Example RESTful API test
    | | [Documentation] | Example of how to test a RESTful service
    | | 
    | | Create session | ${SERVICE_NAME} | ${SERVICE_ROOT}
    | | ${response}= | Get | ${SERVICE_NAME} | /data/2.5/weather?q=chicago,il
    | | 
    | | Should be equal as numbers | ${response.status_code} | 200
    | | ... | Expected a status code of 200 but got ${response.status_code} | values=False
    | | 
    | | ${json}= | To JSON | ${response.content}
    | | :FOR | ${key} | IN
    | | ... | coord | sys | weather | base | main | wind | clouds | dt | id | name | cod
    | | | Run keyword and continue on failure
    | | | ... | Dictionary should contain key | ${json} | ${key} 
    | | | ... | expected json result should contain key '${key}' but did not
    

    【讨论】:

      【解决方案2】:

      这是我关于如何集成 SoapUI 和 RF 的博客: http://qatesterblog.blogspot.com/2018/04/integrating-soapui-into-robot-framework.html

      总结:

      1. 一个关键字由testrunner ith switch运行每个测试用例:-rMI
      2. 使用 XML 库处理 XML 报告。如果发现案件“已完成”,则表示通过。如果没有,将捕获失败消息并抛出 FAIL

      【讨论】:

        猜你喜欢
        • 2021-04-24
        • 2012-02-24
        • 2019-10-25
        • 2012-06-16
        • 2016-05-03
        • 1970-01-01
        • 1970-01-01
        • 2011-07-30
        • 1970-01-01
        相关资源
        最近更新 更多