This could be caused by the applicationContext file looking into a wrong project/(maven)module say for-example when your test is placed in api yet your moduleApplicationContext.xml may be in omod.
You can choose to take one of these three approaches to resolve this:
- Move the moduleApplicationContext.xml file to the project/(maven)module where you have the test such as: api/src/main/resources/ if your test in under api
- Move your test to the project/(maven)module where your moduleApplicationContext.xml
- Separate your moduleApplicationContext.xml into two application context files one in api and the other in omod such that the paths to each of them as;
api/src/main/resources/moduleApplicationContext.xml omod/src/main/resources/webModuleApplicationContext.xml
one in api project/(maven)module contains service/api specific bean definitions only where as the other contains the rest. Examples can be found at:
- https://github.com/openmrs/openmrs-module-allergyapi/blob/master/api/src/main/resources/moduleApplicationContext.xml
- https://github.com/openmrs/openmrs-module-xforms/blob/master/omod/src/main/resources/webModuleApplicationContext.xml
I prefer the last or third one this way paths are righted