This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Using the Test interface and not setting a simple valuePage Title Module

Using the Test interface and not setting a simple value

Hey - I am starting to use the test framework that Spring provides instead of writing my own (which would be hackey...)

But I think that there is something I am fundamentally missing/screwing up.

What is happening is that I am setting a string field through Spring and it seems to not be 'sticking'. Meaning I see it come in (debugger) and then be set to the right value - then when the test runs it is null...here is the code:

Your test class must not be in the context, the spring context framework will wire the dependencies for you based on the beans in the context (I suggest a read of the testing chapter of the spring reference guide).

Simply, remove the setter, put @Autowired on the string, remove the testcase from the xml and only put the String in there. RUn again and it should work.