使用TestRunner访问TestCase属性

时间:2013-08-20 10:05:02

标签: jenkins hudson soapui

我的testCases具有定义为TestCase属性的自定义属性。当我在SoapUI环境中启动测试时,属性值会发生变化,但是当我使用testrunner时没有。

我有一个“当前”var,其中包含要在testCase中使用的当前用户信息。每次TestCase执行当前var增加一个但是当使用testrunner(在jenkins& soapui中)时它不会。增加代码如下,它保存在testCase中包含的Groovy脚本中。

def i = context.testCase.getPropertyValue("_current");    
if(Integer.parseInt(i)+1 < Integer.parseInt(total)) {
    context.testCase.setPropertyValue("_current",String.valueOf(Integer.parseInt(i)+1));    
    log.info("Current user "+testRunner.testCase.getPropertyValue("_current"));
    } else {
    context.testCase.testSuite.setPropertyValue("_current","0");    
        log.info "###__!!! Reached limit of users !!!__###";
    }

我认为testRunner不会执行testCase中包含的groovy脚本。我怎样才能使它发挥作用?

1 个答案:

答案 0 :(得分:1)

我想通了

TestCase和TestSuite属性嵌入在XML项目文件中。要保持更改,需要保存。只需要在testrunner命令中添加-S标志。