You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Jérôme Pochat <jp...@axway.com> on 2015/09/15 16:25:02 UTC

CDITestRunner and mocks

Hi DeltaSpike users

I'm facing issue with running multiple unit tests with CDITestRunner:
- CDI container is not restarted between tests because ScanService consumes lot of time as there a lot of tests.
- Foo service depends on Bar service
- Foo and Bar are ApplicationScoped services

Foo unit test:
- inject Foo reference
- register Bar mock using ApplicationMockManager

Bar unit test:
- inject Bar reference ==> previous Bar mock is injected :-(

How to unregister ApplicationScoped mock from CDI container?

Any tips that could help me?
Thanks in advance.

Re: CDITestRunner and mocks

Posted by Gerhard Petracek <ge...@gmail.com>.
hi,

ApplicationMockManager#addMock just works in @BeforeClass callbacks.
everything else isn't portable across cdi-containers.

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



2015-09-15 16:25 GMT+02:00 Jérôme Pochat <jp...@axway.com>:

> Hi DeltaSpike users
>
> I'm facing issue with running multiple unit tests with CDITestRunner:
> - CDI container is not restarted between tests because ScanService
> consumes lot of time as there a lot of tests.
> - Foo service depends on Bar service
> - Foo and Bar are ApplicationScoped services
>
> Foo unit test:
> - inject Foo reference
> - register Bar mock using ApplicationMockManager
>
> Bar unit test:
> - inject Bar reference ==> previous Bar mock is injected :-(
>
> How to unregister ApplicationScoped mock from CDI container?
>
> Any tips that could help me?
> Thanks in advance.
>