我们已经使用pytest功能使测试用例自动化,但是现在我们必须使用Robot框架来报告和运行测试用例。是否可以使用机械手运行pytest测试用例。
Pytest文件:test_sample.py
import pytest
@pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 24), ("6*9", 54)])
def test_eval(test_input, expected):
print(test_input, expected)
assert eval(test_input) == expected
将由机器人文件调用的执行文件。
exec.py
import os
import sys
def run_test_cases_of(sample_Test):
os.system("pytest -s -v test_sample.py" )
Robot file which is runner:
******settings ***
Library test_sample.py
Library exec.py
****Test Cases ***
Running test case
#test eval # When running through this robot is asking for argument
run test cases of sample_test #When throygh this robot understaing there is only one test case