Sopaui拆解脚本

时间:2016-05-16 11:22:07

标签: soapui

我正在使用拆解脚本进行API测试,以便在每次运行后输入标题值,现在我的脚本就像我的测试套件的第一次运行一样,om我最后一个测试套件我添加了一个拆卸脚本,如下所示

# There are invisible control character escape (U+001B)
name = u'_$B!'
file_name_1 = quote(name) # gives "_%1B%24B%21"
file_name_2 = "_%24B%21.pdf"
content_disposition = "attachment; filename*=utf-8''%s" % file_name_2

所以这将更新我的标题,我可以第二次运行我的测试套件,但我必须更改第三次运行测试套件的标题,所以任何人都可以建议拆卸脚本。

1 个答案:

答案 0 :(得分:0)

没有魔法,你只需编写整个逻辑代码:

def brandTypeFirstRun = "first_value"
def brandTypeSecondRun = "second_value"
def brandTypeThirdRun = "third_value"

def bradTypeCurrentValue = testSuite.project.getPropertyValue("BRAND_TYPE")

if ( bradTypeCurrentValue == brandTypeFirstRun )
    testSuite.project.setPropertyValue("BRAND_TYPE", brandTypeSecondRun)
else if ( bradTypeCurrentValue == brandTypeSecondRun )
    testSuite.project.setPropertyValue("BRAND_TYPE", brandTypeThirdRun)
else if ( bradTypeCurrentValue == brandTypeThirdRun )
    testSuite.project.setPropertyValue("BRAND_TYPE", brandTypeFirstRun)