Unit Test in Maven requires access to the src/main/webapp Directory

后端 未结 4 1233
小鲜肉
小鲜肉 2021-01-04 09:32

I am trying to unit test a webapp that I am developing in Maven/Eclipse. It is a Spring MVC webapp, and I need some unit tests to test my model controller.

To do thi

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 10:10

    To do this, I need to use my webapp config .xml files to inject the controller, however, all my configuration (and other associated files that the configs reference) are in the src/main/webapp directory

    What are those files that you also need during unit tests exactly?

    I do not want to have to copy my entire webapp in to my src/test/resources folder just for the purpose of testing - is there any other way to be able to access them?

    No. If you want them to be on the classpath, put them either in src/main/resources or src/test/resources, files under src/main/webapp are not on the classpath because they're not supposed to.

提交回复
热议问题