简体   繁体   中英

How do I log the request and response in soapUI?

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: 这是我的负载测试

Test Suite

这是我的测试套件

Test case options. I have unchecked the Discard OK results test box. 测试用例选项

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM