How do you validate response time in SOAP UI?

1. Using the "Response Time" Assertion

  • Add the Assertion: Right-click on the Request TestStep in your TestCase and select "Add Assertion" -> "Response Time".
  • Configure the Assertion:
    • Max Time: Set the maximum allowable response time in milliseconds. If the actual response time exceeds this value, the assertion will fail.
    • Unit: Choose the unit for the maximum time (milliseconds, seconds, etc.).

2. Using Groovy Script Assertion

  • Add the Assertion: Right-click on the Request TestStep and select "Add Assertion" -> "Script Assertion".
  • Write the Script:

    

import com.eviware.soapui.support.GroovyUtils

// Get the response time
def responseTime = context.expand('${#Project#Response Time}') 
log.info("Response Time: " + responseTime + " ms") 

// Define the threshold (e.g., 500 milliseconds)
def maxAllowedTime = 500 

// Assert that the response time is within the threshold
assert responseTime <= maxAllowedTime, "Response time exceeded threshold: " + responseTime + " ms" 


3. Analyzing Response Times in Load Tests

  • Create a LoadTest: Right-click on your TestCase and select "New LoadTest".
  • Run the LoadTest: Execute the LoadTest with the desired number of threads and duration.
  • Analyze Results: The LoadTest results will provide detailed statistics on response times, including average, minimum, maximum, and percentiles. You can use these statistics to identify performance bottlenecks and areas for improvement.

Key Considerations

  • Set Realistic Thresholds: Define response time thresholds that are appropriate for your application's requirements and user expectations.
  • Monitor Response Times Over Time: Track response times over time to identify any performance degradation trends.
  • Consider Load Testing: Perform load tests to simulate real-world usage scenarios and assess the API's performance under stress.

By effectively validating response times in SOAP UI, you can ensure that your APIs meet performance expectations and provide a positive user experience.