2

I am calling a REST based service from SoapUI. I have created a load test for the service and the test works. I wrote the following code in my setup script for the load test.

log.info("This is from the setup script")
def request = context.expand('${#Request}')
log.info(request)
def response = context.expand('${#Response}')
log.info(response);

The only item I am getting in my log is the "This is from the setup script". I also added the following lines of code in my Teardown script.

log.info("Teardown script")
def response = context.expand('${#Response}')
log.info(response);

I am not seeing the "Teardown script" text in the log. At this point I am a bit puzzled as to the behavior.

Load Test: This is my load test

Test Suite

This is my test suite

Test case options. I have unchecked the Discard OK results test box. Test case options

What changes do I need to do to my scripts in order to log the requests and the responses?

abhi
  • 3,082
  • 6
  • 47
  • 73

1 Answers1

2

When you create a setup and/or teardown script, remember those are run only once per run, not per test! What you intended is not going to work.

In your setup, since no tests have run yet, the context is going to be empty ... as you can see from your log message.

In your teardown, I suspect there is a bug in SoapUI and the log is not getting sent to the log tab. If you intentionally create an error (I used logg.info "Hello world!" - note the intentional double g), I still got a an error in the error log tab.

SiKing
  • 10,003
  • 10
  • 39
  • 90
  • 1
    So how do I make it log the request / response for each test? – abhi Apr 01 '15 at 16:30
  • 1
    You have to do it as a test step. However, it is important to note that logging will completely defeat the purpose of a load test, as the act of logging will heavily distort the performance. Or, just run your test as a simple SoapUI test, in a loop from command line, with the `-A` option. – SiKing Apr 01 '15 at 16:38
  • I am not familiar with the command line yet, but I have run it in a loop from the UI. – abhi Apr 01 '15 at 20:10
  • You want this http://www.soapui.org/test-automation/running-functional-tests.html then. – SiKing Apr 01 '15 at 20:22