从SoapUI中的另一个TestSuite调用TestCase

时间:2018-09-17 15:10:24

标签: soapui testcase test-suite

SoapUI提供了“运行TestCase功能”:

https://www.soapui.org/docs/functional-testing/teststep-reference/run-testcase.html

问题是我不能仅使用它来定位另一个TestSuite的TestCase。

我知道我可以通过Groovy脚本实现这一目标,但是我想使用图形界面。

是否可以通过图形界面从另一个TestSuite调用TestCase?

谢谢!

2 个答案:

答案 0 :(得分:1)

要在另一个项目中调用测试用例,则必须使用Groovy测试步骤。假设您的项目在同一工作区中,则可以使用:

def workspace = testRunner.testCase.testSuite.project.workspace
def testCase = workspace
    .getProjectByName("Sample SOAP Project Core")
    .getTestSuiteByName("Simple TestSuite")
    .getTestCaseByName("Simple Search TestCase")

def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
testCase.run(properties, false)

我使用了soapUI随附的示例项目。上面的代码位于Sample REST Project的一个测试用例中,并在Sample SOAP Project Core中调用一个测试用例。

答案 1 :(得分:0)

// Replace names of a project, test suite, case and step with those you need.

// Connecting to the test step in another project.
def prj = 
testRunner.testCase.testSuite.project.workspace.getProjectByName("ProjectName")
tCase = prj.testSuites['TestSuiteName'].testCases['TestCaseName']
tStep = tCase.getTestStepByName("TestStepName")

// Calling the test runner and checking if it can run the specified step.
def runner = tStep.run(testRunner, context)
log.info ("runner status ....... : " + runner.hasResponse())
相关问题