Reputation: 1950
I have java project with basic structure src/(main|test)/(java|resources)/... I am using servlet 2.5 and xml configured spring. My BaseDaoTest class looks like this:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
"classpath:spring/datasource-context.xml",
...,
})
@TransactionConfiguration
@Transactional
public abstract class BaseDaoTest extends AbstractTransactionalJUnit4SpringContextTests { }
So under my src/main/resources/spring/ is file datasource-context.xml . For testing I am using in-memory database so I got in src/test/resources/spring also datasource-context.xml .
For about 3/4 year everything was working fine. Test context loaded from src/test and rest from src/main. Althout from yesterday (I don't know what I changed, or what changed) whenever I run all tests in Eclipse (rclick project -> run as -> junit ...) every test case fails. I figured out src/main/... resources are loaded instead of src/test/...
Do anyone know what happend? I can get it working just by renaming the test specific resources but I am curious why the loader (?) changed precendence to load main over test. If I run single test class it works just fine.
Upvotes: 0
Views: 964
Reputation: 1950
My colleague told me to do some sort of epic clean. Eclipse menu bar: Project -> Clean; mvn eclipse:clean; F5; maven force update; generate-source and what not; etc... Now everything works fine as it did. I think the most important part that I have never used before is mvn eclipse:clean.
Upvotes: 0
Reputation: 94429
I suspect your Run configuration settings may have changed. Analyze the run configuration settings on the package back right clicking the package and selecting properties. Then select a run configuration listed within the Run/Debug setting on the left. You want to pay close attention to the class path. Maybe the order of the classpath has changed or directories have been added or removed from the classpath.
Upvotes: 1