Forum Discussion

dlebling's avatar
dlebling
New Contributor
12 years ago

TestCase.run versus logging

I have a TestCase with a Groovy Test Step which runs a different TestCase (whose name is set in a property) on each file in a directory (whose name is set in a property). There are log.info statements to output the names of the files being worked on and the runner status.

(The Groovy Script is below.)

If I run the Groovy Script Test Step directly, I get output. If I run the TestCase containing the Groovy Script, I get no output.

I know that if I run another TestCase from an actual Run TestCase step, rather than in Groovy, I only get output if the Run Mode is "Run primary TestCase". Is this a manifestation of the same issue? If so, how can can make TestCase.run exhibit the same behavior?

Thanks,

Dave Lebling

===
import com.eviware.soapui.model.testsuite.TestRunner.Status

// someDir: the name of a directory
// pattern the pattern of files to match
// returns a File[] array of the matches
def getFilesMatchingPattern(someDir,pattern) {
def files = someDir.listFiles( { dir, file -> file ==~ pattern } as FilenameFilter )
}

// Property 'inputDir' is the directory to use for input
def dir = new File(context.expand ('${#TestCase#inputDir}'))
log.info dir

// Property 'testCaseToRun' is the name of a TestCase in the current TestSuite
def tc = testRunner.testCase.testSuite.testCases[context.expand('${#TestCase#testCaseToRun}')]

// testCaseToRun must have an 'inputFile' property
getFilesMatchingPattern(dir, /.*\.xml/).each { file ->
log.info file.canonicalPath
tc.setPropertyValue("inputFile", file.canonicalPath)
def runner = tc.run(null, false)
log.info "Status: $runner.status"
assert runner.status != Status.FAILED : runner.reason
}
===
No RepliesBe the first to reply