tags:

views:

45

answers:

1

All time am getting below error message in groovy...

Could not understand whats causing this " Unexpected token error" ????

I used to think only PERL give bad compilation error,now groovy outperforming it..

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
D:\Playground\groovy\release-b-work\cmd_line_soapui\trial.groovy: 12: 
unexpected token: myrunner @ line 12, column 1.    
myrunner.setProjectFile("D:\soapui-release-B\try.xml");
      ^
  1 error

Code taken from comment;

import com.eviware.soapui.SoapUIProTestCaseRunner;
import com.eviware.soapui.support.*;
import com.eviware.soapui.model.*;
import com.eviware.soapui.impl.wsdl.*;
import com.eviware.soapui.*;
class trial {
  def myrunner = new com.eviware.soapui.SoapUIProTestCaseRunner();
  myrunner.setProjectFile("D:\soapui-release-B\try.xml");
  myrunner.setTestSuite("MediaAssetServiceTestSuite");
  myrunner.setTestCase("createMediaAsset TestCase");
  myrunner.run();
} 
+1  A: 

You need to put your code in a method

You can't just add code into a class at class level

Try:

import com.eviware.soapui.SoapUIProTestCaseRunner;
import com.eviware.soapui.support.*;
import com.eviware.soapui.model.*;
import com.eviware.soapui.impl.wsdl.*;
import com.eviware.soapui.*;

class trial {
  def someMethod() {
    def myrunner = new com.eviware.soapui.SoapUIProTestCaseRunner();
    myrunner.setProjectFile("D:\soapui-release-B\try.xml");
    myrunner.setTestSuite("MediaAssetServiceTestSuite");
    myrunner.setTestCase("createMediaAsset TestCase");
    myrunner.run();
  }
} 
tim_yates
sorry, I got another groovy error now ..Caught: groovy.lang.GroovyRuntimeException: This script or class could not be run.It should either:- have a main method,- be a JUnit test, TestNG test or extend GroovyTestCase,- or implement the Runnable interface.
karthi
dump....I should also add Main method !! .. Problem solved !!
karthi