chihhsiw
14 years agoOccasional Contributor
How does groovy script gets context from setup script?
Hello,
I am running load test in soapUI free version and I have the following 3 scripts in 1 testcase
1. setup script
context.logger = new FileWriter(filePath+ "thread_testing.txt", true)
anArray = new String[2]
anArray[0] = "Cheese"
anArray[1] = "Pepperoni"
context.anArray = anArray
2. teardown script
context.logger.println "Time taken: " + loadTestRunner.timeTaken
context.logger.close()
3. groovy script in 1 of the test step
context.logger.println "In groovy step thread idex is " + context.ThreadIndex
ThreadIdxVal = context.ThreadIndex
log.info("Thread index is $ThreadIdxVal")
log.info("context.anArray " + context.anArray[0])
setup and teardown scripts work fine and I got in output file
Time taken: 3203
But I got null object on context.anArray and context.logger in groovy script
1. apparently the groovy script step does not get the same context.logger which setup in setup script but teardown script gets
it. Any idea on how to fix it?
2. how does groovy script get context.anArray values which setup in setup script?
thanks
chihhsiw
I am running load test in soapUI free version and I have the following 3 scripts in 1 testcase
1. setup script
context.logger = new FileWriter(filePath+ "thread_testing.txt", true)
anArray = new String[2]
anArray[0] = "Cheese"
anArray[1] = "Pepperoni"
context.anArray = anArray
2. teardown script
context.logger.println "Time taken: " + loadTestRunner.timeTaken
context.logger.close()
3. groovy script in 1 of the test step
context.logger.println "In groovy step thread idex is " + context.ThreadIndex
ThreadIdxVal = context.ThreadIndex
log.info("Thread index is $ThreadIdxVal")
log.info("context.anArray " + context.anArray[0])
setup and teardown scripts work fine and I got in output file
Time taken: 3203
But I got null object on context.anArray and context.logger in groovy script
1. apparently the groovy script step does not get the same context.logger which setup in setup script but teardown script gets
it. Any idea on how to fix it?
2. how does groovy script get context.anArray values which setup in setup script?
thanks
chihhsiw