Junit + getResourceAsStream Returning Null

后端 未结 13 1362
情话喂你
情话喂你 2020-12-15 03:32

Not sure how this is possible. I re-read up on getResourceAsStream and it\'s always returning null.

InputStream source = this.getClass().getResourceAsStream(         


        
13条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 03:32

    Assuming test.xml is located right under your test root source folder, do this:-

    InputStream source = this.getClass().getClassLoader().getResourceAsStream("test.xml");
    

提交回复
热议问题