需求:向jmeter.jmx 的路径下 写日志 ;
1 import org.apache.jmeter.services.FileServer; 2 import com.bzj.utils.*; 3 String baseDir=FileServer.getFileServer().getBaseDir(); 4 log.info("baseDir="+baseDir); 5 String filePath = baseDir+"${filePath}"; 6 log.info("公共变量中的文件路径:"+filePath); 7 ReadOrWriteFile fwriter= new ReadOrWriteFile(filePath); 8 fwriter.writeFile("注册的用户名:uname= "+"${spTestUser}");
${__BeanShell(import org.apache.jmeter.services.FileServer;FileServer.getFileServer().getBaseDir();)} ;
log.info(System.getProperty("file.separator")});
${__property(file.separator)}获取到当前系统的路径分隔符
log.info(System.getProperty("user.dir"));
log.info(System.getProperty("java.home"));
log.info(System.getProperty("file.separator"));