hi,

if you enable

deltaspike.testcontrol.mock-support.allow_manual_injection-point_manipulation
the 2nd (re-)injection step (before each test-method) will be skipped.

regards,
gerhard



2018-06-12 12:41 GMT+02:00 [email protected] <[email protected]>:

> I'm using Deltaspike Test-Control for testing with JUnit within CDI
> container, which works pretty nice for "scoped" beans. However I'm getting
> troubles with dependent beans. Hier is an example:
>
> public class DependentBean {
>         private String val;
>         // getter/setter
>
> }
>
> @RunWith(CdiTestRunner.class)
> public class DependentBeanTest {
>         @Inject
>         private DependentBean bean;
>
>         @Before
>         public void before() {
>                 System.out.println("before() bean: " +
> System.identityHashCode(bean));
>                 bean.setVal("nonnull");
>         }
>
>         @After
>         public void after() {
>                 System.out.println("after() bean: " +
> System.identityHashCode(bean));
>         }
>
>         @Test
>         public void test() {
>                 System.out.println("test() bean: " +
> System.identityHashCode(bean));
>                 Assert.assertNotNull(bean.getVal());
>         }
>
> }
>
> Output:
> before() bean: 794894657
> test() bean: 479460026
> after() bean: 479460026
>
> The test fails and the output say, that in method before() the reference
> to the bean is not the same as in methods test() and after(). Thus, the
> bean is being injected twice.
>
> Is it a bug or such behavior is expected?
>

Reply via email to