Api JMeter:可撤销的BeanShell断言?

Api JMeter:可撤销的BeanShell断言?,api,jmeter,Api,Jmeter,我正在执行基本CRUD功能的API测试。为了在每个线程组中创建每个记录类型,我使用了为每个线程组定制的相同BeanShell断言模板 import org.apache.jmeter.services.FileServer; if (ResponseCode != null && ResponseCode.equals("200") == true) { SampleResult.setResponseOK(); } else if (!ResponseCode.equal

我正在执行基本CRUD功能的API测试。为了在每个线程组中创建每个记录类型,我使用了为每个线程组定制的相同BeanShell断言模板

import org.apache.jmeter.services.FileServer;

if (ResponseCode != null && ResponseCode.equals("200") == true) {
SampleResult.setResponseOK();  
}
else if (!ResponseCode.equals ("200") == true ) { 
    Failure = true;
    FailureMessage ="Creation of a new {insert record type} record failed. Response code " + ResponseCode + "." ; // displays in Results Tree
    print ("Creation of a new {insert record type} record failed: Response code  " + ResponseCode + ".");   // goes to stdout
    log.warn("Creation of a new {insert record type} record failed: Response code " + ResponseCode); // this goes to the JMeter log file

// Static elements or calculations
part1 = "\n FAILED TO CREATE NEW {insert record type} RECORD via POST. The response code is: \"";
part2 = "\". \n\n - For \'Non-HTTP response code - org.apache.jorphan.util.JMeterStopThreadException\' is received,verify the payload file still exists. \n - For response code = 409, \n\t a) check the payload for validity.\n\t b) verify the same {insert record type} name doesn't already exist in the {insert table name} table. If found, delete record and re-run the test. \n - For response code = 500, verify the database and its host server are reachable. \n";

// Open File(s)
FileOutputStream f = new FileOutputStream(FileServer.getFileServer().getBaseDir() + "\\error.log", true);

//FileOutputStream f = new FileOutputStream("c:\\error.log", true); 
PrintStream p = new PrintStream(f); 

// Write data to file 
p.println( part1 + ResponseCode + part2 );

// Close File(s)
p.close();
f.close();
}
有没有一种方法可以使这个断言重新调用,而不是在每个线程组中重复它?现在我最多有20个线程组,因此这个断言有20个版本


我已经看过这个网站上的多个页面,也看过了,但是我没有找到解决这个问题的方法。感谢您的反馈。

如果您将断言(任何断言)置于与线程组相同的级别,如:

它将应用于“采样器1”和“采样器2”。此外,在每次迭代中,断言将应用于每个线程组中的每个采样器


请参阅澄清断言范围、成本和最佳实践的指南。

谢谢。我要试一试。