I have a maven spring project (latest version) and I want to write some junit tests (latest version).
The issue I have is that my spring beans are autowired, and when I call them from junit test, I get null pointer exceptions, as spring doesn’t autowire them.
How can I load the context so that things are autowired?
Have you studied Testing chapter in Spring reference documentation? Here is an example you should start with:
If you are in
com.example.MyTestin/src/test/java, you will need/src/test/resources/com/example/MyTest-context.xml– but the exceptions will show you the way.