Discussion:
[testng-dev] Is there any way to integrate TestNG with CDI?
r***@gmail.com
2017-07-06 02:06:54 UTC
Permalink
Hi,

I want to be able to test my JPA persistence layer and some code that is
based on it. I am using Weld 3.0 and Deltaspike to integrate JPA and
@Transactional behavior
I managed to statr/stop container, inject any dependencies into a test
instances via TestNG annotated methods - it works. But it is lame because I
could not find a way to use CDI to actually instantiate test as beans so
TestNG is in charge of test instantiation and creates it without the
benefit of CDI and thus @Transactional is not working. Is there any way to
customize TesNG to delegate test instantiation to CDI? I saw Guice
integration (did not explore it) but nothing about CDI

Or any other way to integrate transactional. I guess I could use one of the
TestNG listeners to star/stop transactions for transitionally annotated
test methods but I was hoping for a more complete solution where TestNG
lets me intercept test instantiation before dong all of its things with it
and invoking its methods

Thanks
Alex
--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.
Julien Herr
2017-07-14 17:12:02 UTC
Permalink
Hi,

TestNG doesn't support CDI out of the box.

But some third parties like Aquillian or TomEE
<https://tomee.apache.org/developer/testing/applicationcomposer/index.html>
integrate JavaEE/CDI with TestNG.
Maybe you should a look to them.

Julien
Post by r***@gmail.com
Hi,
I want to be able to test my JPA persistence layer and some code that is
based on it. I am using Weld 3.0 and Deltaspike to integrate JPA and
@Transactional behavior
I managed to statr/stop container, inject any dependencies into a test
instances via TestNG annotated methods - it works. But it is lame because I
could not find a way to use CDI to actually instantiate test as beans so
TestNG is in charge of test instantiation and creates it without the
customize TesNG to delegate test instantiation to CDI? I saw Guice
integration (did not explore it) but nothing about CDI
Or any other way to integrate transactional. I guess I could use one of
the TestNG listeners to star/stop transactions for transitionally annotated
test methods but I was hoping for a more complete solution where TestNG
lets me intercept test instantiation before dong all of its things with it
and invoking its methods
Thanks
Alex
--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.
Loading...