简单的函数调用在 Robot Framework 中不起作用
Simple function calling doesn't work in Robot Framework
刚接触Robot FW,正在学习阶段。为了尝试调用外部库,我做了一个非常简单的函数并保存在 tryingLibrary.py
文件中。内容:
def myAdding(x, y):
z = x + y
return z
然后我写了下面的射频测试
*** Settings ***
Documentation Suite description
Library tryingLibrary.py
*** Variables ***
${x}
*** Test Cases ***
TestTest
${x}= myAdding 30 26
但是,当我检查日志文件时,我发现 ${x} = 3026
。我的意思是我当然期待 56
而不是 3026
那么问题可能出在哪里呢?
你可能想看看这个documentation
文档明确指出参数类型是 Unicode 字符串。有两种方法可以实现您想要的行为
在python函数中这样转换
def myAdding(x, y):
z = int(x) + int(y)
return z
使用方法如下,这里是doc
*** Test Cases ***
TestTest
${x}= myAdding
刚接触Robot FW,正在学习阶段。为了尝试调用外部库,我做了一个非常简单的函数并保存在 tryingLibrary.py
文件中。内容:
def myAdding(x, y):
z = x + y
return z
然后我写了下面的射频测试
*** Settings ***
Documentation Suite description
Library tryingLibrary.py
*** Variables ***
${x}
*** Test Cases ***
TestTest
${x}= myAdding 30 26
但是,当我检查日志文件时,我发现 ${x} = 3026
。我的意思是我当然期待 56
而不是 3026
那么问题可能出在哪里呢?
你可能想看看这个documentation
文档明确指出参数类型是 Unicode 字符串。有两种方法可以实现您想要的行为
在python函数中这样转换
def myAdding(x, y): z = int(x) + int(y) return z
使用方法如下,这里是doc
*** Test Cases *** TestTest ${x}= myAdding