Note that there are some explanatory texts on larger screens.

plurals
  1. POsoapUI: How to access Test Step property from assertion script?
    primarykey
    data
    text
    <p>I'm new to SoapUI and Groovy, but an experienced Java programmer.</p> <p>I created a TestCase with two Test Steps:</p> <ol> <li>Properties step called <code>CID</code> with single property <code>correlationID</code> and value <code>${=java.util.UUID.randomUUID()}</code>.</li> <li><code>Test Request</code> where I put <code>&lt;CorrelationID&gt;${correlationID}&lt;/CorrelationID&gt;</code> in the request.</li> </ol> <p>It works perfectly and submits unique <code>CorrelationID</code> value every time I run my tests.</p> <p>Now I want to add new Script Assertion to Test Step 2 (<code>Test Request</code>) that compares computed <code>correlationID</code> property value from Test Step 1 (<code>CID</code>) with some data from Test Step 2 response. The problem is that I can not seem to be able to access generated value of <code>correlationID</code> from there.</p> <p>If I try this: <code>log.info "${correlationId}"</code></p> <p>I get: <code>No such property: correlationId for class: Script19</code></p> <p>If I try this: <code>log.info "${CID#correlationId}"</code></p> <p>I get:</p> <pre><code>startup failed: Script43.groovy: 1: unexpected char: '#' @ line 1, column 16. log.info "${CID#correlationId}" ^ org.codehaus.groovy.syntax.SyntaxException: unexpected char: '#' @ line 1, column 16. at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:97) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:71) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:158) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:814) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727) at groovy.lang.GroovyShell.parse(GroovyShell.java:739) at groovy.lang.GroovyShell.parse(GroovyShell.java:766) at groovy.lang.GroovyShell.parse(GroovyShell.java:757) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:148) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93) at com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.GroovyScriptAssertion.assertScript(GroovyScriptAssertion.java:116) at com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.GroovyScriptAssertion.internalAssertResponse(GroovyScriptAssertion.java:133) at com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion.assertResponse(WsdlMessageAssertion.java:156) at com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequest.assertResponse(WsdlTestRequest.java:189) at com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequest.setResponse(WsdlTestRequest.java:159) at com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.run(WsdlTestRequestStep.java:346) at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runTestStep(WsdlTestCaseRunner.java:207) at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(WsdlTestCaseRunner.java:138) at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.internalRun(WsdlTestCaseRunner.java:39) at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: Script43.groovy:1:16: unexpected char: '#' at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:695) at org.codehaus.groovy.antlr.parser.GroovyLexer$1.nextToken(GroovyLexer.java:248) at groovyjarjarantlr.TokenBuffer.fill(TokenBuffer.java:69) at groovyjarjarantlr.TokenBuffer.LA(TokenBuffer.java:80) at groovyjarjarantlr.LLkParser.LA(LLkParser.java:52) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.nls(GroovyRecognizer.java:780) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.openOrClosableBlock(GroovyRecognizer.java:8848) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.stringConstructorValuePart(GroovyRecognizer.java:13449) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.stringConstructorExpression(GroovyRecognizer.java:11932) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.primaryExpression(GroovyRecognizer.java:11091) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.argumentLabel(GroovyRecognizer.java:10863) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.commandArgument(GroovyRecognizer.java:10756) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.commandArguments(GroovyRecognizer.java:10173) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.expressionStatement(GroovyRecognizer.java:8948) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1258) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:650) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:93) ... 31 more 1 error </code></pre> <p>How can I access that <code>correlationId</code> computed value from my assertion Groovy script?</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload