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

后端 未结 4 1262
小鲜肉
小鲜肉 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:15

    You can achieve this using maven-surefire-plugin as below:

        
            org.apache.maven.plugins
            maven-surefire-plugin
            
                
                    src\main\webapp\
                
            
        
    

    Now you can access your web.xml in this way for example:

    getClass().getClassLoader().getResourceAsStream("classpath:webapp/WEB-INF/web.xml")
    

提交回复
热议问题