在(手动)更新单个SoapUI测试步骤的JDBC连接属性之后
${property}
扩展)?我有一个SoapUI项目,其中包含许多指向我的开发数据库的JDBC测试步骤:
JDBC TestStep的开源版本具有用于设置的字段 手动连接属性和SQL查询。 Getting Started | JDBC (SoapUI.org)
约束:我目前正在使用Smartbear专业版的 Connections 功能。
在部署之前,我想在我们的暂存环境中运行相同的测试,即我必须在整个测试套件中更改JDBC连接设置。
初步考虑因素: 为了将所有JDBC步骤重定向到登台数据库,我可以将我的测试编辑为依赖于属性扩展的连接字符串和驱动程序字段,如SOAPUI ability to switch between database connections for test suite中所述。
具体方法:
但是在这种情况下,我需要直接在测试步骤上查看连接字符串和驱动程序(与仅查看${expansion}
变量相反) - 基本原理:它提供了更实用的屏幕截图......
答案 0 :(得分:0)
可以使用以下Groovy脚本将连接属性从一个测试步骤复制到项目中的其他JDBC测试步骤:
// Select "correctly configured" JDBC TestStep/Case/Suite to be used as reference
def s = testRunner.testCase
.testSuite
.project
.testSuites["Reference TestSuite"]
.testCases["Reference TestCase"].getTestStepAt(1)
log.info "${s.getConnectionString()}, ${s.getDriver()}"
// Use s to configure all JDBC TestSteps in current TestSuite
testRunner.testCase
.testSuite
.testCases
.each{iTC, testCase ->
//log.debug "${iTC}: ${testCase}"
testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.JdbcRequestTestStep)
.each{testStep ->
testStep.setConnectionString(s.getConnectionString())
testStep.setDriver(s.getDriver())
log.info "${testStep.getConnectionString()}, ${testStep.getDriver()}"
}
}
为了运行此功能,我分别引入了一个额外的测试套件internal TS
和测试用例internal TC
。我已将上面脚本的Groovy TestStep copyJdbcSettings
添加到internal TC
并执行了一次。
然后我禁用了internal TS
,直到有一天我再次需要它。