繁体   English   中英

需要从另一个测试套件的安装脚本运行测试步骤(常规步骤)。 但是没有可用的testRunner

[英]Need to run a test step(groovy step) from another testsuite's setup script. But no testRunner available

我有一个reusbale_libraries testSuite,它具有不同的可重用类作为测试用例/测试脚本。 该类之一是脚本中的excelreader。 我需要从另一个测试套件的setupscript调用此excelreader脚本,并使用excelreader脚本中的类将包含从excel工作表读取的所有数据的数组初始化为一个数组。 数组中的数据将被该测试套件中的所有测试用例使用。但是我无法从测试套件中调用脚本,因为测试套件没有testRunner变量。 如何调用该excelreader脚本? 如果没有办法,维护可重用库并在测试包/测试用例/脚本中使用它的最佳方法是什么?

Example code:
In TestSuite1's setup script: 

//def testRef=testRunner.testCase.testSuite.project.testSuites["TestSuite 
4"].testCases["TestCase 1"]
//testRef.Run(testRunner,context) //throws exception testRunner not avl.

def tc=testSuite.project.testSuites["TestSuite 4"].testCases["TestCase 1"]
tc.testSteps["tc1_script2"].run(testSuite.testRunner,context) //this also 
throws exception

mobj=context.getProperty("obj")
log.info(mobj.fun())

In Testsuite2's Testcase1's testscript1:

class test1{
def fun(){return "test1"}
}
obj= new test1()
context.setProperty("obj",obj)

那时还没有TestCaseRunner 你可以自己做。

import com.eviware.soapui.support.types.StringToObjectMap
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner

def testCase = runner.testSuite.project
    .testSuites["TestSuite 4"]
    .testCases["TestCase 1"]

def testRunner = new WsdlTestCaseRunner(testCase, new StringToObjectMap())
testRunner.runTestStepByName("tc1_script2")

assert testRunner.runContext.obj

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM