Forum Discussion

czyzyk29's avatar
czyzyk29
Contributor
12 years ago

test runner problem Soap ui pro

Hi,

I have problem with play test in test runner -> jenkins.

I have project with some enviroments
- trunk
- dev
and with some data base JDBC, diffrent for trunk and diffrent for dev:

- I open Soap UI change on project env = trunk
- play TC and it's OK
- change project env = dev
- play TC and it's OK

- have change on project env = trunk
- I try play with test runner (lauch testrunnef from soap ui) but in Overrides i change env = dev
- test Falult because data source don't change data base, the take values from trunk

I have soap ui pro 5.0, and have envent to refresch enviroment and data connection like this:


def databaseName = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionAt(0).getName()

def connectionString = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getConnectionString()


for(testStep in context.testCase.getTestStepList())
{
if(testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep)
{
if(!(testStep.getDataSource() instanceof com.eviware.soapui.impl.wsdl.teststeps.datasource.GridDataSource))
{
if(testStep.disabled == false)
{

testStep.getDataSource().databaseConnection.setConnectionString(connectionString)
}
}
}
}




This functionality is importent when i whan to play test on different enviroments and bases in jenkins from testrunner for example.
Its look's like u can have 1 poroject for 1 data base.

Unfortunately I can't sent may project.

Please help

2 Replies

  • Hi,

    This sounds similar to an internal defect of SOAP-1013 and reported on forum link viewtopic.php?f=4&t=14279&p=53164#p53164. As a workaround you can use this script to update the jdbc connection when changing environment.

    Add this to event handler TestRunListener.beforeRun

    /* Work with more than one JDBC connection set per environment, also does not modify connection strings when JDBC TestStep is not configured using a Project-Level JDBC connection */

    // Iterate all test steps in the test case and change connectionString for all ProJdbcRequestTestStep to the selected environment connectionString.

    for(testStep in context.testCase.getTestStepList())
    {

    // Set the connectionString for all ProJdbcRequestTestStep
    if(testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.ProJdbcRequestTestStep)
    {
    // Get databaseName
    def databaseName = testStep.getJdbcRequestTestStepConfig().getDbConnectionName()
    if(databaseName != null)
    { // Get connectionString of active environment def connectionString = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getConnectionString() testStep.setConnectionString(connectionString) // Get connection password of active environment def connectionPassword = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getPassword() testStep.setPassword(connectionPassword) }

    }
    }


    http://www.soapui.org/Scripting-Propert ... dlers.html
  • It's not working with your handler. In Soap UI and in Testrunner I have failed tests because of wrong data source (wrong connnection to data base)


    In may first post I give you my event with refresh of my enviroment - only in Sopa UI not in testrunner.

    May I discribed better.
    I have 2 enviroments connect with 2 data base
    -env trunk -> trunk base
    -env dev -> dev base
    In data source I connect to this data base by Data Connection, it's JDBC connection.
    In event TestRunListener.beforeTestStep I refresh Data Connection and refresh datasource (I add connection password)

    //take database Name
    def databaseName = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionAt(0).getName()
    //take connection String
    def connectionString = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getConnectionString()
    def connectionPassword = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getPassword()

    //for all step in test case
    for(testStep in context.testCase.getTestStepList())
    {
    //if therr are data source
    if(testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep)
    {
    //not be a grid (i have same grids in project)
    if(!(testStep.getDataSource() instanceof com.eviware.soapui.impl.wsdl.teststeps.datasource.GridDataSource))
    {
    //not by disabled
    if(testStep.disabled == false)
    {
    //change connection string
    testStep.getDataSource().databaseConnection.setConnectionString(connectionString)
    testStep.getDataSource().databaseConnection.setPassword(connectionPassword)
    }
    }
    }
    }


    It't work fine in SOAP UI but not in Testrunner.