@HttpTest(method = Method.PUT, path = "/v1/deliveries/" + DELIVERY_ID, headers = { @Header(name = "Accept-Encoding", value = "multipart/form-data") }, content = "{}" type = MediaType.MULTIPART_FORM_DATA, file="myfile.txt")
public void testUpdateDeliveryDetails()
{
assertEquals("204 response if Delivery is successfully updated", Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
myfile.txt包含多部分表单数据,我想在此单元测试中加载它,但即使我在类路径中有该txt文件,它也会给我一个restfuse错误,说"" myfile。 TXT"不在课程路径中。我正在使用eclipse,任何人都可以告诉我应该放置这个文件的位置,并且会读取这个文件的内容,如何在filename属性标签中声明文件名?
我收到以下错误
Caused an ERROR
[junit] Could not open file myfile.txt. Maybe it's not on the classpath?
[junit] java.lang.IllegalStateException: Could not open file myfile.txt. Maybe it's not on the classpath?
答案 0 :(得分:0)
将该文件放入测试资源&提供带斜杠的文件路径 文件=" /myfile.txt"