문제

I want to assert multiple variables in one single Response Assertion pattern. A method exists to verify an OR of multiple values, but i haven't found one for AND.

For example, to assert values v1, v2, or v3 - you could add in the Response Assertion > Patterns to Test >Add : v1|v2|v31. The test will pass if any one of them is found in the response. This also works with the || operator.

I need something that gives me the same flexibility with an AND condition. I'm currently having to add one pattern for each value I want to assert, and this is extremely painful to do, especially with a long assertion list.

Does anyone know of a way to combine assertion patterns using some kind of an AND operator? I have tried obvious ones, &, &&, ., +,etc. but no luck thus far.

도움이 되었습니까?

해결책 2

I thinks that Beanshell Assertion is that what you're looking for, it gives as much flexibility as you can think of.

Example AND-based assertion code will look like:

String response = new String(ResponseData);

if (response.contains(vars.get("v1")) && response.contains(vars.get("v2"))) {
    Failure = false;
} else {
    Failure = true;
    FailureMessage = "Specified conditions were not met";
}

You can refer to How to use BeanShell: JMeter's favorite built-in component guide for more detailed explanation and kind of cookbook.

다른 팁

When you add multiple lines to the Response Assertion the default operation is to AND the lines.

A separate line for each V1, V2, V3 equals V1&V2&V3.

This means you can also mix. A line for V1 and a line for V2|V3 equals V1&(V2|V3).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top