JMeter document processing

1, the interface will return information written to a file

//从用户注册接口的返回结果中获取userid、username、token,缺省值为“NULL”
if
(vars.get("userid").equals("NULL") == false&&vars.get("username").equals("NULL") == false&&vars.get("token").equals("NULL") == false){
  FileWriter fstream = new FileWriter(".\\usersinfo.csv",true);
  BufferedWriter out = new BufferedWriter(fstream);
  out.write(vars.get("userid")+","+vars.get("username")+","+vars.get("token")+"\n");
  out.close();
  fstream.close();
}

2, the number of rows read data files (the number of cycles may be controlled by the number of lines cycler file)

Import org.apache.jmeter.services.FileServer;
 Import com.bzj.utils *. ;
 Import java.io.BufferedReader;
 Import java.io.FileReader; 

String fname = vars.get ( "filename" ); 
String the baseDir = FileServer .getFileServer () getBaseDir ();. // get the script to the directory where the 
String filePath = + baseDir "the Data \\ \\" + fname; // spliced into the path of the file to be read 

BufferedReader br = new new BufferedReader ( new new FileReader ( filePath)); 
String tmpStr = "" ;
 int rowNum = 0 ;
 the while ! (tmeStr br.readLine = () = null){
    rowNum++;
}
rowNum = rowNum - 1;
vars.put("cycleNum",rowNum.toString());

 

Guess you like

Origin www.cnblogs.com/scholars-xian/p/11685508.html