Problem with Testing for web app based on multi modules

(Manuel Jordan) #1

Hello Developers

I have a Spring Web app working with multi-modules (it comes from other project based in one-module)

I can export the app into a .war file and deploy it with Tomcat and all works fine.

My problem is about testing.

Just playing with:

@ContextConfiguration(classes={RootApplicationContextConfig.class, ServletApplicationContextConfig.class})
public class PersonaRetrieveControllerTest {

	private WebApplicationContext webApplicationContext;

	private MockMvc mockMvc;

	private static Persona persona;

	public static void beforeClass(){
		persona = PersonaFactory.crearPersonaMix();

	public void setUp(){
		mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();

	public void abc(){


I always get the following:

Caused by: ServletContext resource [/WEB-INF/tiles/definition/tiles-definitions.xml] cannot be resolved to URL because it does not exist

Remember: the app runs fine in tomcat

The module being testing is

project(':web-27-controller') {
	description 'Web - Controller & Rest'
	dependencies {
	   compile project(':web-27-service-api')
	   compile project(':web-27-support')
 	   testCompile project(':web-27-context')
 	   testRuntime project(':web-27-web')


And it depends in someway to :web-27-web' (here no testing)

project(':web-27-web') {
	description 'Web (JSP, JS, CSS)'
	apply plugin: 'war'
	dependencies {
				compile project("$it")
		//Apache Tiles
	 	].each { 
	 		testRuntime "org.apache.tiles:$it:$tilesVersion"
	 		runtime "org.apache.tiles:$it:$tilesVersion"
		compile "javax.servlet:jstl:$jstlVersion"
		testRuntime "javax.servlet:jstl:$jstlVersion"
		//Servlet API
		providedCompile "javax.servlet:javax.servlet-api:$javaxServletApiVersion"
		testRuntime "javax.servlet:javax.servlet-api:$javaxServletApiVersion"
	war {
		baseName = warBaseName

In this :web-27-web module I can see the path to the /WEB-INF/tiles/definition/tiles-definitions.xml file. Furthermore in this module exists all about web files such as: html, js, css, images, and tiles (xml) and again, the app runs fine in tomcat

My current configuration about Gradle would be verbose or perhaps illogic since I’ve tried many combinations.

The obvious question is: why works in production and not in testing.

I am working with testRuntime and nothing.

I already have read:

What is missing about testing configuration?

Thank you