0

tl;dr

After (manually) having updated the JDBC connection properties of a single SoapUI test step,

  • how can I copy them to the other test steps in the project (without resorting to ${property} expansion)?
  • I suppose Groovy is the key?

Background

I have a SoapUI Project containing many JDBC test steps pointing to my development database like that:

The Open source version of JDBC TestStep has fields for setting the connection properties and the SQL query manually. Getting Started | JDBC (SoapUI.org)

Constraint: I am currently working without having the Connections feature from Smartbear's Pro version available.

Goal

Before deploying, I want to run the same tests in our staging environment i.e. I have to change JDBC connection settings throughout the test suite(s).

Preliminary considerations: In order to re-direct all JDBC steps to the staging database I could edit my tests to connection string and driver fields relying on property expansion like described in SOAPUI ability to switch between database connections for test suite.

Specific approach: However in this case here, I need to see the connection strings and drivers directly on the test steps (in contrast to seeing just the ${expansion} variables) – Rationale: it gives more useful screenshots with the real values ...

Community
  • 1
  • 1
fheub
  • 249
  • 5
  • 14

1 Answers1

0

The connection properties can be copied from one test step to other JDBC test steps in the project using the following Groovy script:

// 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()}"
                    }
        }

To run this, I have introduced an additional test suite internal TS and test case internal TC, respectively. I have added a Groovy TestStep copyJdbcSettings with above script to internal TC and executed it once. I have then disabled internal TS until I need it again someday.

fheub
  • 249
  • 5
  • 14