我已经在suite中动态创建了套件和测试用例。我想使用重新运行失败的测试用例 pybot-重新运行失败的C:\ Users \ GS-0815 \ PycharmProjects \ Apex \ out1.xml-输出C:\ Users \ GS-0815 \ PycharmProjects \ Apex \ Failed \ out1.xml“ + suite.name 结果:
但是它说没有找到健全的套房
用于测试脚本的PFA(无法附加rtf / txt文件),我如何提供动态创建的套件路径或其他任何方式
在此处粘贴代码.........
import os
from robot.libraries.BuiltIn import BuiltIn
from robot.libraries.BuiltIn import *
from robot.api import TestSuite
from robot.api import ResultWriter
from robot.parsing.model import TestData
#from robot.output import TestSuite
from robot.running.context import EXECUTION_CONTEXTS
class TestRunner():
ROBOT_LISTENER_API_VERSION = 2
ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
def init(self):
print "in init"
def func(self,a):
BuiltIn().log_to_console("in testrunner.py")
self.ROBOT_LIBRARY_LISTENER = self
#suite=EXECUTION_CONTEXTS.current.suite
suite = TestSuite(name='Sanity',source=a)
suite.configure()
BuiltIn().log_to_console(suite)
#BuiltIn().import_resource("C:/Users/GS-0815/PycharmProjects/Apex/demo.robot")
print a
suite.resource.imports.library('OperatingSystem')
suite.resource.imports.library('C:/Users/GS-0815/PycharmProjects/Apex/keyw.py')
#BuiltIn().import_resource('C:/Users/GS-0815/PycharmProjects/Apex/TestSuites/test.robot')
suite.resource.imports.resource("C:/Users/GS-0815/PycharmProjects/Apex/TestSuites/test.robot")
suite.keywords.create("t1",args=['in suite setup'],type="setup")
test = suite.tests.create('WirelesswithSegmentation', tags=['smoke','abc'])
test.keywords.create("abc", args=["hi","there","ddgdgd"])
#test.keywords.create('Environment Variable Should Be Set', args=['SKYNET'])
test = suite.tests.create('Test2', tags=['smoke'])
#test.keywords.create('abc', args=['test2'],type='setup')
test.keywords.create('Log to Console', args=['EXECUTION_CONTEXTS.current.suite'], type='setup')
test.keywords.create('Log to Console', args=['&&&&&&&&&&&&&&&'])
test.keywords.create('Log to Console', args=['test21'])
test = suite.tests.create('Test3', tags=['xyz'])
test.keywords.create('Log to Console', args=['hi there3'])
suite2 = TestSuite('regression')
suite2.resource.imports.library('OperatingSystem')
#suite2.resource.imports.library('demo.robot')
#suite.resource.imports.library('C:/Users/GS-0815/PycharmProjects/Apex/keyw.py')
test = suite2.tests.create('WirelesswithSegmentation2', tags=['he','abc'])
test.keywords.create('Log to Console', args=['hi there'])
#suite.filter(included_tags=['xyz'])
result =suite.run(output='out1.xml')
result2=suite2.run(output='out2.xml')
**os.system("pybot --rerunfailed C:\Users\GS-0815\PycharmProjects\Apex\out1.xml --output C:\Users\GS-0815\PycharmProjects\Apex\Failed\out1.xml "+suite.name**
os.system('rebot -d C:\Users\GS-0815\PycharmProjects\Apex\TestSuites out1.xml out2.xml')
ob = TestRunner()
ob.func('C:\Users\GS-0815\PycharmProjects\Apex\TestSuites\suite1.robot')
答案 0 :(得分:0)
我认为您有2种选择:
答案 1 :(得分:0)
我利用创建的output.xml来获取失败的套件以及Tcs的列表,然后再次将这些套件传递给suite.run()函数。