【问题标题】:SoapUI: Why Project properties are not updating when i run all tests with TestrunnerSoapUI:为什么当我使用 Testrunner 运行所有测试时项目属性没有更新
【发布时间】:2014-10-27 12:27:56
【问题描述】:

当我使用“Launch TestRunner”在我的项目中运行所有测试时,我在更新 SoapUI 中的项目属性时遇到了一些问题。

我有两个带有测试的 TestSuite。所有的测试用例都有第一步 - groovy 脚本。此脚本在所有测试用例中都相同:

Integer curIdAndKey = new Integer (testRunner.testCase.testSuite.project.getPropertyValue( "IdAndKey" ))
Boolean curBool = new Boolean (testRunner.testCase.testSuite.project.getPropertyValue( "bool" ))
Integer curTestsCount =new Integer( testRunner.testCase.testSuite.project.getPropertyValue( "countOfTests" ))
if(curBool==false){
    curBool=true
    curIdAndKey= curIdAndKey*curTestsCount
}
else {
    curIdAndKey += 1
}

testRunner.testCase.setPropertyValue("aIdCase", curIdAndKey.toString())
testRunner.testCase.testSuite.project.setPropertyValue("bool", curBool.toString())
testRunner.testCase.testSuite.project.setPropertyValue("IdAndKey", curIdAndKey.toString())
log.info "Current Id : [$curIdAndKey]"
log.info "Current bool : [$curBool]"

我有一个项目属性:“IdAndKey”和“bool”。 当我运行单个 TestCase - 这个项目属性正在更新,但是当我运行所有测试时,它们没有更新(我只在日志中看到更新,但在属性中没有看到)。 请帮帮我。

【问题讨论】:

  • 已经在这里回答了:stackoverflow.com/q/26460598/3124333
  • 不,不一样。我需要从 SoapUI 而非命令行运行测试。
  • 您说:... 使用“启动 TestRunner”。这样就一样了!

标签: groovy soapui


【解决方案1】:

Launch TestRunner 窗口中的一个选项,在 Basic 选项卡下,是:“Save After”。选择此选项并按启动。您会注意到-S 开关(在链接的重复帖子中讨论)被添加到命令行中,显示在下一个窗口中。

其他讨论虽然已经过时,但在official docs 中。

【讨论】:

  • 我的项目属性IdAndKey是钢一样的,它的变化只在日志中可见,但经过测试运行值相同:(
  • 关闭并打开项目。
  • 谢谢,它的作品,但有没有关闭和打开项目的任何其他方式?
  • 你在做什么听起来不像正常的工作流程。如果你能描述一下你想要完成的是什么。
【解决方案2】:

尝试使用以下内容:

def globalProps = context.testRunner.testCase.testSuite.project;
globalProps.setPropertyValue("aIdCase", curIdAndKey.toString());

让我知道它是否有效。

【讨论】:

  • 在我的情况下它可以工作,我还使用了一些全局道具,并将它们保存在项目属性中。
猜你喜欢
  • 1970-01-01
  • 2019-07-05
  • 1970-01-01
  • 2013-12-09
  • 2021-08-14
  • 1970-01-01
  • 2022-11-18
  • 1970-01-01
  • 2013-10-12
相关资源
最近更新 更多