में काम नहीं कर रहा है मुझे यकीन है कि मुझे कुछ आसान याद आ रहा है। बार जूनिट टेस्ट में बार आ जाता है, लेकिन फू के अंदर बार क्यों नहीं आ जाता है?Autowire जूनिट परीक्षण
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"beans.xml"})
public class BarTest {
@Autowired
Object bar;
@Test
public void testBar() throws Exception {
//this works
assertEquals("expected", bar.someMethod());
//this doesn't work, because the bar object inside foo isn't autowired?
Foo foo = new Foo();
assertEquals("expected", foo.someMethodThatUsesBar());
}
}
आपका मतलब क्या है, "फू के अंदर बार"? – skaffman