从测试套件拆卸脚本访问测试用例 属性
Access test case property from test suite tear down script
我正在尝试从测试套件拆卸脚本访问测试用例属性。
我无法使用测试运行器属性。
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )
需要使用测试用例名称访问测试用例属性。
如果有人能回答的话会很有帮助。
要访问测试套件 属性,这只是您的拆卸脚本中的一个例子....
def someProp = context.expand( '${#TestSuite#someProp}' )
现在,我使用的是 Pro 版本,但我不知道您使用的是什么,所以我不确定我的下一部分回答是否有帮助。
在安装脚本、拆卸脚本、脚本断言中,您可以 'right-click' 在代码 window 中键入脚本,上下文中有一个 'Get Data' 菜单项菜单。这使您可以 select 感兴趣的数据。事实上,上面的代码行是使用 'Get Data' 上下文菜单选项生成的。
要访问套件拆卸脚本中给定测试用例的自定义 属性,您需要这样做...
def testCase = testSuite.testCaseList.find { p -> p.name == 'TestCase 2' }
def testProp = testCase.getProperty('testCaseProp');
log.info(testProp.value);
您使用的语法不正确
试试这个
def testCs = testRunner.testCase.testSuite.project.testSuites["name of testsuite"].getTestCaseByName(name)
def tcprop = testCs.getPropertyValue("NameOftestCaseProp")
我们首先获取测试用例的引用,然后访问其 属性
或以下也应该有效
def testcaseProp= testRunner.testCase.testSuite.project.testSuites["name of testsuite"].getTestCaseByName(name).getPropertyValue("name of property)
尝试你觉得简单的那个,虽然两者是一样的
我正在尝试从测试套件拆卸脚本访问测试用例属性。
我无法使用测试运行器属性。
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )
需要使用测试用例名称访问测试用例属性。
如果有人能回答的话会很有帮助。
要访问测试套件 属性,这只是您的拆卸脚本中的一个例子....
def someProp = context.expand( '${#TestSuite#someProp}' )
现在,我使用的是 Pro 版本,但我不知道您使用的是什么,所以我不确定我的下一部分回答是否有帮助。
在安装脚本、拆卸脚本、脚本断言中,您可以 'right-click' 在代码 window 中键入脚本,上下文中有一个 'Get Data' 菜单项菜单。这使您可以 select 感兴趣的数据。事实上,上面的代码行是使用 'Get Data' 上下文菜单选项生成的。
要访问套件拆卸脚本中给定测试用例的自定义 属性,您需要这样做...
def testCase = testSuite.testCaseList.find { p -> p.name == 'TestCase 2' }
def testProp = testCase.getProperty('testCaseProp');
log.info(testProp.value);
您使用的语法不正确
试试这个
def testCs = testRunner.testCase.testSuite.project.testSuites["name of testsuite"].getTestCaseByName(name)
def tcprop = testCs.getPropertyValue("NameOftestCaseProp")
我们首先获取测试用例的引用,然后访问其 属性
或以下也应该有效
def testcaseProp= testRunner.testCase.testSuite.project.testSuites["name of testsuite"].getTestCaseByName(name).getPropertyValue("name of property)
尝试你觉得简单的那个,虽然两者是一样的