Forum Discussion

robertc's avatar
robertc
Occasional Contributor
16 years ago

How do I determine the type of a test step in a groovy script

I am reading environment variables in from an ini file in my test suite setup script and updating the properties for each step. However the JDBC step does not like properties that are not used in the SQL so I want to avoid updating the properties for a JDBC step.

My code looks like:

for (tcase in testSuite.testCaseList) {
    for (tstep in tcase.testStepList) {
tstep.setPropertyValue("Endpoint", props.getProperty ( "Endpoint" ))
tstep.setPropertyValue("Username", props.getProperty( "Username" ))
tstep.setPropertyValue("Password", props.getProperty ( "Password" ))
    }
}

I want it to be the following

for (tcase in testSuite.testCaseList) {
    for (tstep in tcase.testStepList) {
        if (tstep.type <> 'JDBC Request') {
            tstep.setPropertyValue("Endpoint", props.getProperty ( "Endpoint" ))
    tstep.setPropertyValue("Username", props.getProperty( "Username" ))
    tstep.setPropertyValue("Password", props.getProperty ( "Password" ))
        }
    }
}

I tried tstep.config.type but that always returns 'request' regardless of the step type.

I have search the API but could not find what I am looking for.

Any suggestions would be appreciated.

Robert

4 Replies

  • robertc's avatar
    robertc
    Occasional Contributor
    Sorry but that gives error No such property.
  • Yes, my mistake.  There is a method inherited from java.lang.object called getClass().

    tstep.getClass() should return the class object
  • robertc's avatar
    robertc
    Occasional Contributor
    Thanks, that is exactly what I want. I see I need to hone up on my Java knowledge.
    Cheers
    Robert