0
我創建了一個jmeter,它在我的網站上下了訂單並記錄訂單狀態和確認編號。訂單被預訂後,我使用BeanShell PostProcessor將提取的變量打印到文件中。我真的很想能夠爲文件名添加日期,但我一直無法找到辦法。Jmeter和Filewriter - 爲文件名添加日期+時間戳
這是我的豆殼後處理器的樣子:
FileWriter fstream = new FileWriter("C:\\JMeter\\Results\\log.csv",true);
BufferedWriter out = new BufferedWriter(fstream);
out.write(vars.get("scriptName"));
out.write(System.getProperty("line.separator"));
out.write("STATUS: " + vars.get("status"));
out.write(System.getProperty("line.separator"));
out.write("Confirmation Number: " + vars.get("ConfirmationNumber"));
out.write(System.getProperty("line.separator"));
out.write("");
out.write(System.getProperty("line.separator"));
out.write("");
out.close();
fstream.close();
我曾嘗試把各種變量納入文件名,但我懷疑我已經做了錯誤的,因爲甚至正在創建任何文件。
完全免責聲明(根據上面的示例代碼,這可能不是必需的):我不是代碼人,所以請原諒代碼。
在此先感謝。
謝謝你的時間,塞爾瓦。這正是我所需要的,但我不確定如何設置$ {__ P(UNIQUEID,$ {__ time(YMDHMS)})}屬性,以便我可以使用它。我試着將它添加到user.properties文件中,但它看起來並不是要走的路。 – Mari
使用你的建議我想出了一個不同的方式來實現這一點,非常感謝! – Mari
您可以在測試計劃的頂部添加一個'用戶定義的變量'配置元素並添加一行並定義它。名稱:UNIQUEID,值:$ {__ P(UNIQUEID,$ {__ time(YMDHMS)})} – Selva