-1

Here is the script that I am using:

import.groovy.json.JsonSlurper

def response==messageExchange.response.responseContext

def json = new JsonSlurper().parseText(response)

assert context.FirstTestCase().getPropertyValue("contractNumber")==json.results[3].object

The result I am getting:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script3.groovy: 1: unexpected token: import @ line 1, column 1. import.groovy.json.JsonSlurper ^ org.codehaus.groovy.syntax.SyntaxException: unexpected token: import @ line 1, column 1. at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:223) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:191) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:233) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:189) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:966) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:626) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:323) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:293) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:677) at groovy.lang.GroovyShell.parse(GroovyShell.java:689) at groovy.lang.GroovyShell.parse(GroovyShell.java:725) at groovy.lang.GroovyShell.parse(GroovyShell.java:716) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:835) Caused by: Script3.groovy:1:1: unexpected token: import at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1331) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:666) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:214) ... 20 more 1 error

craigcaulfield
  • 3,381
  • 10
  • 32
  • 40

1 Answers1

0

Extra characters

I spotted two errors in the script.

  1. Extra '.' in line 1
  2. Extra '=' in line 3

Line 1 should say import.groovy, but you have import..groovy

Line 3 should say def response= but you have def response==

Terry Ebdon
  • 487
  • 2
  • 6
  • Thanks Terry but this solution didn't work.The result that i posted says that the error is in line 1 of the script. And I am not able to replicate why its is coming. – NaiveTester Jul 27 '20 at 16:02
  • I don't have ''import..groovy" in the code. The script is written in the correct way. Any other solution will be welcomed. – NaiveTester Jul 28 '20 at 10:57
  • It's in the first line of your code: `import.groovy.json.JsonSlurper`. You need to remove the '.' between 'import' and 'groovy'. – Terry Ebdon Jul 28 '20 at 11:04