SoapUI:当我使用Testrunner运行所有测试时,为什么Project属性不会更新

时间:2014-10-27 12:27:57

标签: groovy soapui

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

我有两个带测试的TestSuite。所有TestCase都有第一步 - groovy脚本。这个脚本在所有TestCase中都是一样的:

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时 - 这个项目属性正在更新,但是当我运行所有测试时,它们没有更新(我看到只在日志中更新,但在属性中没有更新)。 求你帮帮我。

2 个答案:

答案 0 :(得分:0)

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

其他讨论虽然过时,但仍在official docs

答案 1 :(得分:0)

尝试使用以下内容:

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

让我知道它是否有效。

相关问题