hi stephen, #1 you need to register your mock correctly (in your case with NamedLiteral, since you are using @Named) #2 dependent-scoped beans are a bit special. if you are using a dynamic lookup via BeanProvider#getContextualReference in your test, the instance gets created/injected after you registered your mock -> with that your test passes
regards, gerhard http://www.irian.at Your JavaEE powerhouse - JavaEE Consulting, Development and Courses in English and German Professional Support for Apache MyFaces, DeltaSpike and OpenWebBeans 2018-04-12 22:27 GMT+02:00 Stephen More <[email protected]>: > My real problem turns out to be an issue with Injecting Mock Dependent > Beans.... > > I made a fork of: > https://github.com/os890/javase-cdi-ds-project-template/tree/mock-demo > which can be found here: > > https://github.com/mores/javase-cdi-ds-project- > template/tree/mockingInterface > > ApplicationScopedBean == 14 > DependentBean == 2 > > SimpleTest == 28 = 14 x 2 ----- all is good > > Now lets mock it up.... > ApplicationScopedBean == 7 > DependentBean == 3 > > SimpleMockTest > I want 21 = 7 * 3 > > But I get 14 = 7 * 2 ( mocked DependentBean client is ONLY > SimpleMockTest ) > > > What is the proper way to inject and mock a Dependent Bean ? > > -Thanks >
