Forum Discussion

duccio_fabbri's avatar
duccio_fabbri
New Contributor
9 years ago

Issue with WsdlMockRunner isRunning()

When a mock service is stopped, it seems getMockRunner() returns "null".

Is it ok?!

 

Here is my code:

 

 

def wsdlMockService = testRunner.testCase.project.mockServices["ServiceSoapBinding MockService"]

wsdlMockService.start()
try{
     if (wsdlMockService.getMockRunner().isRunning())
        log.info("+++++++++ Mock is running")
    else
        log.info("+++++++++ Mock is NOT running")}
catch(Exception e)
{
    log.info("++++ ERROR: " + e.getMessage())}
 
wsdlMockService.getMockRunner().stop()

try{
     if (wsdlMockService.getMockRunner().isRunning())
        log.info("------- Mock is running")
    else
        log.info("------- Mock is NOT running")}
catch(Exception e)
{

     log.info("---- ERROR: " + e.getMessage())}

RESULTS:

 

  • Wed Sep 14 23:55:35 CEST 2016:INFO:+++++++++ Mock is running
  • Wed Sep 14 23:55:35 CEST 2016:INFO:---- ERROR: Cannot invoke method isRunning() on null object
  • nmrao's avatar
    nmrao
    Champion Level 3

    You script is actually missing the object in color

    Here is the script to start mock service:

     

    //To start mock service
    //Change the service name as needed. def name = 'GlobalWeatherSoap MockService' def wsdlMockService = testRunner.testCase.testSuite.project.mockServices[name] wsdlMockService.start() if (wsdlMockService.getMockRunner().isRunning()) { log.info("+++++++++ Mock is running") }

    Stop script:

     

    //To stop mock service
    //Change service name as needed.
    def name = 'GlobalWeatherSoap MockService'
    def wsdlMockService = testRunner.testCase.testSuite.project.mockServices[name]
    wsdlMockService.getMockRunner().stop()

     

     

    • duccio_fabbri's avatar
      duccio_fabbri
      New Contributor

      Thank you for your hint. I tried but I have the same issue.

      After the line:

      wsdlMockService.getMockRunner().stop()

      the istruction:

      wsdlMockService.getMockRunner().isRunning()

      returs the error:

       

      • Thu Sep 15 13:20:32 CEST 2016:INFO:---- ERROR: Cannot invoke method isRunning() on null object

      If I comment the line with .stop(), no error.

       

      I don´t understand if this is by design or not.

       

      Thanks

      • nmrao's avatar
        nmrao
        Champion Level 3
        The sample code snippets provided to you after testing them only.

        You can just try to add a test case with two separate groovy scripts, and both and try.