需求:向jmeter.jmx 的路径下 写日志 ;
import org.apache.jmeter.services.FileServer;
import com.bzj.utils.*;
String baseDir=FileServer.getFileServer().getBaseDir();
log.info("baseDir="+baseDir);
String filePath = baseDir+"${filePath}";
log.info("公共变量中的文件路径:"+filePath);
ReadOrWriteFile fwriter= new ReadOrWriteFile(filePath);
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"));