如何传递对象变量测试用例RobotFramework? [英] How to pass object-variables to test cases in RobotFramework?
问题描述
下面是发生了什么事情(一般),与我的基于Python测试。
Here's what's going on (generically) with my python-based test.
==============================================================================
***Settings***
Variables variable_file.py
Library library.py
***Test Cases***
A Test Case
myTest ${some string} [I want to pass an object here]
=============================================================================
最后,我想通过这一直是我的变量文件中定义的实际类对象。我看着远近没有找到一个方式来传递任何超出字符串或列表。有谁知道怎么样?
At the end, I want to pass an actual class object which has been defined inside my variable file. I've looked far and wide without finding a way to pass anything beyond a string or a list. Does anyone know how?
推荐答案
默认情况下,$ {}变量是字符串,但它也可以包含对象。
你也可以把它传递给关键字参数。
By default, ${variable} are strings, but it can also contain objects. And you can pass it to keywords as argument.
以这样一个简单的例子:
Take a simple example like that:
${mydict} = Create Dictionary a 1 b 2
=>然后有$ {mydict} = {'一个':'1','B':'2'}
=> Then you have ${mydict} = {'a': '1', 'b': '2'}
然后你就可以调用你的对象作为参数的关键字。例如:
And then you can call a keyword with your object as argument. For example:
Dictionary Should Contain Key ${mydict} a
我使用的那种事来测试REST API发送我JSON。我存储JSON对象机器人变量,并通过探索字典的内容检查结果。我在一个博客文章解释这一点。
这篇关于如何传递对象变量测试用例RobotFramework?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!