SoapUI Pro Project Solution Collection-change the JDBC Request behavior
change the jdbc request :
1.change the driver name,connection string,query string or assert.
- the object we will use here is : JdbcRequestTestStep
TestCase newcase=testRunner.getTestCase(); JdbcRequestTestStep step1=(JdbcRequestTestStep) newcase.getTestStepByName(""); String driver=step1.getDriver(); String constr=step1.getConnectionString(); String password=step1.getPassword(); step1.setDriver(""); //if there's no driver should set as step1.setDriver(null) step1.setConnectionString(""); step1.setPassword("");
- change the jdbc sql statement:
step1.setQuery("");
step1.setQueryTimeout("");
- change the assertion behavior(like xpath string,jquery string):
http://www.soapui.org/apidocs/com/eviware/soapui/model/testsuite/TestAssertion.html
int totalassert=step1.getAssertionCount(); for(int k=0;k<totalassert;k++){ TestAssertion asserts=step1.getAssertionAt(k); if(asserts instanceof XPathContainsAssertion ){ if(asserts.getName().contains("Check count")){ String originalxpath=((XPathContainsAssertion) asserts).getPath(); String newxpath=originalxpath.replaceAll("Row", "Row2"); ((XPathContainsAssertion) asserts).setPath(newxpath); } } }
作者:高级测试开发网
博客地址:https://seniortesting.club
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。