【问题标题】:Calling a TestCase from another TestSuite in SoapUI在 SoapUI 中从另一个 TestSuite 调用 TestCase
【发布时间】:2019-02-21 13:27:00
【问题描述】:

SoapUI 提供“运行测试用例功能”:

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

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

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

有没有办法通过图形界面从另一个TestSuite调用TestCase?

谢谢!

【问题讨论】:

  • 根据您提供的链接:您选择 Target TestSuite 和 Target TestCase。你还需要什么?
  • 问题是TestSuite 输入中显示的唯一TestSuite 是包含我正在工作的TestCase 的那个,尽管我在同一个项目中有许多其他TestSuite。我无法选择另一个 TestSuite。
  • 这听起来像是一个错误……或者您的设置有问题。我一直使用这个功能没有问题。 Run TestCase 是一项专业功能,因此您应该能够向他们提交错误:support.smartbear.com/readyapi/docs/support.html
  • 我可以看到它在soapUI 5.4 和ReadyAPI 2.5 中工作。您可以使用soapUI 附带的示例项目对其进行测试,看看您是否获得了与您的项目相同的行为。
  • 其实我的错,我不能做的是从另一个项目中选择一个TestCase。从另一个 TestSuite 中选择一个 TestCase 在单个项目中可以正常工作。有没有办法从另一个项目调用 TestCase ?

标签: soapui testcase test-suite


【解决方案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 的测试用例。

【讨论】:

    【解决方案2】:
    // 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())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 2020-11-11
      • 1970-01-01
      • 1970-01-01
      • 2010-09-17
      • 1970-01-01
      相关资源
      最近更新 更多