1
votes

Hello. I met the following problem.

What I should do:

  1. I need to make a performance test of services. I don't have documentation. In this case, I record the requested services and responses using Jmeter and the browser. Then I review every one sample and add a regular expression extractor - if it's needed.

What's the problem?

  1. The problem that I met is when I run the script from Jmeter, some requests have two or more responses. When I use regular expression extractor or response assertion, I noticed that the extractor or assertion is applied only to the last response. So can I apply the regular expression extractor and response assertion to responses that I need?
  2. Here are some screenshots for more details:

This picture shows that we have two responses from one request and you can see details about the first response.

This picture shows details about the second response.

This picture shows the response code for the first response.

Same as the previous picture, but I added a Response Assertion - to check if the assertion works for the first response.

This picture shows the response code for the second response.

This picture shows the assertion failure.

Why has this has happened?

  1. Probably this happened because I hit an URL (endpoint), and this URL forces other requests, that weren't recorded. So... maybe I need to configure the recorder options in another way.

Whats the questions:

  1. Is there is a way to choose what response I can use with a regular expression extractor? For example, there are two responses and I want to use a regular expression extractor to the first one.
  2. Which are the best settings for recording using Jmeter?
1

1 Answers

0
votes

"Whats the answers":

  1. No, you have choice between Main sample and sub-samples, main sample only, sub-samples only or JMeter Variable
  2. The ones which are defined in the Recording Template are most probably the best, at least they're better than anything else I've seen so far. The general approach of "recording" might be a big mistake itself, at least for Web 2.0, I believe there are way better options of replicating browser traffic.

Coming back to your first question and possible solutions: you're basically being redirected that's why you're getting 2 subresults, one with status code 302 and another one with 200

With normal Response Assertion you can only amend its configuration to take both status codes as successful:

enter image description here

If you want to test that exactly the first subresult has status code of 302 - you will have to go for JSR223 Assertion and implement the acceptance criteria in Groovy.

Example code:

if (prev.getSubResults().first().getResponseCode() != '302') {
    AssertionResult.setFailure(true)
    AssertionResult.setFailureMessage('Response code mismatch, expected: 302, got: ' + prev.getSubResults().first().getResponseCode())
}