Junit + getResourceAsStream Returning Null

后端 未结 13 1406
情话喂你
情话喂你 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:38

    It's not finding the resource on the classpath. If you are using junit and maven make sure the resources are copied on the target/test-classes by adding file directive on section

    You can also find out the location of your class in the file system by using

    this.getClass().getResource(".")
    

    and checking to see if the resource is there

提交回复
热议问题