我想在 Jmeter 中使用 beanshell 断言找到丢失的元素

I want to find the missing elements using beanshell assertion in Jmeter

我有两个 get api,它给出了将 id 作为变量之一的响应代码

因此,使用 Jason 提取器,我提取了名称为 id1 和 id2

的 api 的 ID

我已经使用 bean shell 断言来比较两个 id 的

数据是这样的:

id1:{abc,qwe,ert,yup,iop,bnm,dff} 等等

id2 :{qwe,ert,iop,bnm,dff} 这样有数百个数据存在

有没有办法在使用 beanshell 断言比较两个 ID 后只打印丢失的数据,如果是,请帮助我。

Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting 所以我不会用 Beanshell 来“帮助你”,而是提供 Groovy-based 解决方案。

示例代码:

def id1 = org.apache.commons.lang.StringUtils.substringBetween(vars.get('id1'), '{', '}').split(',').collect()
def id2 = org.apache.commons.lang.StringUtils.substringBetween(vars.get('id2'), '{', '}').split(',').collect()

def missing = org.apache.commons.collections.CollectionUtils.disjunction(id1, id2)

和演示:

更多信息:Scripting JMeter Assertions in Groovy - A Tutorial