简体   繁体   English

在JMeter中使用Excel中的数据进行数据驱动的测试时出错

[英]Error while doing Data-Driven Testing in JMeter using data in Excel

I am attempting to read xmls stored in one column of an Excel spreadsheet and fire them to a server using HTTP Sampler and then store the response xml in the same Excel. 我试图读取存储在Excel电子表格的一列中的xml,然后使用HTTP Sampler将它们发射到服务器,然后将响应xml存储在同一Excel中。 This is the structure of my test plan in JMeter: 这是我在JMeter中测试计划的结构: 在此处输入图片说明

However I have encountered and error. 但是我遇到了错误。 I am not able to pinpoint the exact place where the error is taking place but I have obtained the error message from the Results Tree are as follows: 我无法查明发生错误的确切位置,但是我从结果树中获得了错误消息,如下所示:

for the JSR223 Sampler 用于JSR223采样器

Response message: javax.script.ScriptException: Sourced file: inline evaluation of: import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . . . '' : Typed variable declaration : Attempt to resolve method: parseInt() on undefined variable or class name: INTEGER : at Line: 6 : in file: inline evaluation of: 响应消息:javax.script.ScriptException:源文件:内联评估: import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . . . '' : Typed variable declaration : Attempt to resolve method: parseInt() on undefined variable or class name: INTEGER : at Line: 6 : in file: inline evaluation of: import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . . . '' : Typed variable declaration : Attempt to resolve method: parseInt() on undefined variable or class name: INTEGER : at Line: 6 : in file: inline evaluation of: import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . . . '' : Typed variable declaration : Attempt to resolve method: parseInt() on undefined variable or class name: INTEGER : at Line: 6 : in file: inline evaluation of: import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . . . '' : Typed variable declaration : Attempt to resolve method: parseInt() on undefined variable or class name: INTEGER : at Line: 6 : in file: inline evaluation of: import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . 导入org.apache.poi.xssf.us。 . . '' : INTEGER .parseInt ( vars .get ( "counter" ) ) in inline evaluation of: ``import org.apache.poi.xssf.usermodel.XSSFWorkbook; '':INTEGER .parseInt(vars .get(“ counter”))的内联评估:``import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . 导入org.apache.poi.xssf.us。 . . '' at line number 6 ''在第6行

The error in the HTTP Request Sampler's Response Data tab reads as: HTTP请求采样器的“响应数据”选项卡中的错误显示为:

Exception occured: Parsing xml error, xml string is:${RQI}

BeanShell Assertion error is : BeanShell断言错误是:

Assertion error: true Assertion failure: false Assertion failure message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``import org.apache.poi.xssf.usermodel.XSSFWorkbook; 断言错误:true断言失败:false断言失败消息:org.apache.jorphan.util.JMeterException:调用bsh方法错误:eval在文件中:内联评估:``import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.us . 导入org.apache.poi.xssf.us。 . . '' Encountered ":" at line 6, column 65. ”在第6行第65列遇到了“:”。

This is the code that I had used in the JSSR223 Sampler in the While Controller: 这是我在While控制器中的JSSR223采样器中使用的代码:

import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFRow;
import java.io.*;

int i = INTEGER.parseInt(vars.get("counter"));
XSSFRow row = vars.getObject("book").getSheetAt(0).getRow(i);

vars.putObject("row", row);
for (int j = 1; j <= vars.getObject("book").getSheetAt(0).getRow(0).getLastCellNum(); j++) {
    if (row.getCell(j) == null) {
        row.createCell(j).setCellValue("");
    }
}

String payload = row.getCell(1).toString();
 vars.put("RQI",payload);
//String password = row.getCell(2).toString();
// vars.put("password",password);
//String expectedResult = row.getCell(5).toString();
// vars.put("expectedResult",expectedResult);

Please assist. 请协助。 Also, feel free to ask for more information as I have left out the code for the other JSR223 Samplers in this post for brevity. 另外,为简洁起见,在本文中我省去了其他JSR223采样器的代码,请随时询问更多信息。 Thank you in advance. 先感谢您。

  1. You must change this line: 您必须更改此行:

     INTEGER.parseInt(vars.get("counter")); 

    to this one 到这个

     Integer.parseInt(vars.get("counter")); 

    check out Integer class JavaDoc - Integer.parseInt() 检出Integer类JavaDoc- Integer.parseInt()

  2. You should be using JSR223 Test Elements instead of Beanshell test elements and you should be using Groovy language in the JSR223 Test Elements 您应该使用JSR223测试元素而不是Beanshell测试元素,并且应该在JSR223测试元素中使用Groovy语言

  3. You might find How to Implement Data Driven Testing in your JMeter Test reference useful. 您可能会在JMeter测试参考中发现如何实施数据驱动测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel电子表格中的数据驱动的单元测试 - Data-Driven Unit Test from Excel Spreadsheet 使用Excel工作表在Cucumber中进行数据驱动测试 - Data driven testing in Cucumber using Excel sheets 使用 Excel 进行赛普拉斯数据驱动测试 - Cypress Data Driven Testing with Excel 用量角器进行数据驱动的测试 - Data Driven testing with Protractor 通过在 Selenium webdriver 和数据驱动测试中使用带有 Apache POI 的 Excel 表读取数据来选择 Angular 材料下拉选项 - Selecting Angular material drop down option by reading data using excel sheet with Apache POI in Selenium webdriver and Data driven testing 在Excel数据驱动的单元测试中使用数据源相对路径时出错 - Error using Data Source relative path in Excel Data Driven Unit Test Soap UI-数据驱动测试-Apache POI错误 - Soap UI-Data driven testing-Apache POI error Selenium C# 从 Excel 读取数据,用于基于 SheetName 的数据驱动测试 - Selenium C# reading data from Excel for data driven testing Based On SheetName 使用openrowset从SQL将数据导出到Excel时出现错误 - while exporting data to excel from sql using openrowset getting error 使用apache POI和java访问excel数据时出错 - Getting error while accessing excel data using apache POI and java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM