Forum Discussion

jvictoor's avatar
jvictoor
Occasional Contributor
15 years ago

TestSuite Mock should recieve 3 responses

Hi,

I'm rather new to SOAPUI and I'm creating technical tests for our alsb service. now i have One request and that request will be sent to 2 consumers. So I've build 2 mocks and they receive the request ok. We also have a split in our service, so when i send the request, the message is send to the mock n-times.

I made a request that has to be split in 3 requests. So my mock should receive 3 requests and my other mock 1 request. This is somewhat my situation.

so
request1->alsb-|->mock1
|->mock2
|->mock2
|->mock2


Now I want to test this with a testsuite.

I have step 1, send request and then i have 4 mock steps. But this does not work.
the first problem is that the responses are send quicker than the test step could start up.
the second problem is that the mocks are serial. By that I mean that all responses arrive at the same time, but the mock will start the next one when the previous one is processed.

I think the sollution is pretty simple, but I don't know how to accomplish it.
this is how my test suite should look like
start my first mock service
start my second mock service
send my request
check my first mock service if he received 1 response
check my second mock service if he received 3 responses
shutdown my mocks

Thanks in advance

6 Replies

  • jvictoor's avatar
    jvictoor
    Occasional Contributor
    Little update.

    I found that i can use groovy to start my mocks

    so now i have a start step, an request step and a stop step
    the start step
    def project = testRunner.testCase.testSuite.project
    log.info project.name
    def myMock = project.getMockServiceByName("My-Mock")
    def myMockRunner = myMock.start()

    myMockRunner.setLogEnabled(true)
    // place the object on the context
    context.setProperty("myMockRunner",myMockRunner)

    the stop step
    def myMockRunner = context.getProperty("myMockRunner")
    if(myMockRunner.isRunning()){
    myMockRunner.stop()
    }


    the only thing that i now have to do, is check how many request the mock received. Due to the lack of documentation in the soapUI api, I don't find how i should do this. Write my own listener or is it possible to do this with the code available?

    I allready tried to configure a counter that places a value on the context of the Mock service, but in the test suite, I cannot access the context of the Mock Service
  • jvictoor's avatar
    jvictoor
    Occasional Contributor
    Isn't there anyone who can help me? This problem does not seem so hard?
    I had expected soapui would support this.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    The MockRunner has a method "getMockResultCount", which may be what you are looking for.

    Regards,
    Dain
    eviware.com
  • jvictoor's avatar
    jvictoor
    Occasional Contributor
    eviware support wrote:

    Hello,

    The MockRunner has a method "getMockResultCount", which may be what you are looking for.

    Regards,
    Dain
    eviware.com

    The method getMockResultCount does always return 0, I don't know what this method does, but it does not return the correct number.
  • jvictoor's avatar
    jvictoor
    Occasional Contributor
    I'm using 3.0
    I have a sort of solution, but it ain't pretty.
    I use a testsuite as a testcase. So my testsuite contains 3 mock services and 1 soap request. I start them parallel. When the test receive 3 requests, the test is successfull.