java - How to have an object autowired and injected just once in a JUnit+Spring Test? -
i have test case have @autowired foo foo
need have injected once, test methods re-use same data foo
has. happening upon every @test
method's invocation, foo
bean cleanly re-loaded spring.
is possible load bean once whole test class , how done?
this behavior environment specific since differ in loading of spring context. example, eclipse not automatically reload context between tests maven does.
i suggest write @before
method copies @autowired
reference field , have tests use field.
Comments
Post a Comment