我正在放心地測試 API,編程語言是 JAVA,我沒有什麼問題,問題是,我必須使用放心發送圖像,並且在本地成功發送了圖像,但是當我將其推送到 git 時,指定路徑有問題,我所有的測試都在 TeamCity 上運行,我得到了我的黃瓜報告,報告如下
java.io.FileNotFoundException: C:\Users\nameOfUser\Downloads\38250987.jpeg(系統找不到指定的路徑)
我希望我已經提供了足夠的描述性問題,如果您有任何問題,如有疑問,請提出您的問題,希望得到您的幫助與合作,在此先感謝!
代碼如下
public static Response SendAnImage(String prodID,Cookies cookies) {
File file = new File("C:\\Users\\userName\\Downloads\\38250987.jpeg");
System.out.println("is file found ----> "+file.exists());
Response response = given()
.multiPart("file", file, "image/jpeg")
.when()
.cookies(cookies)
.post("/api/product/"+prodID+"/file/false");
return response;
}
您可以將文件放在src/test/resources
文件夾中,然後像這樣創建一個新文件:
File file = new File("src/test/resources/38250987.jpeg");
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句