-
1. Re: How to use CDI and before/after with UI tests?
mjobanek Jan 6, 2016 4:35 AM (in response to chschulz)Hi,
the injection doesn't work because the methods are run on a client, not in a container. The rule for junit is:
The whole test class or at least one of the test methods is intended to be run on a client => before/after methods are invoked on a client (CDI is NOT supported)
The whole test class (including all test methods) is intended to be run in a container => before/after methods are invoked in a container (CDI is supported)
You could use ShrinkWrap to add a servlet into your deployment that will insert and clean the data. Then it would be possible to call this servlet in before/after methods running on a client.
There is another workaround, but very complicated and not nice - replace before/after methods by test methods running in a container and launch the test methods in a appropriate sequence.
Best
Matous
-
2. Re: How to use CDI and before/after with UI tests?
bmajsak Jan 11, 2016 10:12 AM (in response to mjobanek)There is also another way to achieve before/after behaviour but that would lead you to implement your own extension and pass commands to Arquillian through CommandService. If you are brave enough to follow this path I can give you some pointers
Cheers,
Bartosz
-
3. Re: How to use CDI and before/after with UI tests?
chschulz Jan 12, 2016 1:47 AM (in response to bmajsak)Sounds interesting. I would try to achieve that approach.
-
4. Re: How to use CDI and before/after with UI tests?
bmajsak Jan 12, 2016 4:06 AM (in response to chschulz)Cool, let me prepare some gists. Will do it this evening
Cheers,
Bartosz
-
5. Re: How to use CDI and before/after with UI tests?
chschulz Jan 18, 2016 5:37 AM (in response to bmajsak)Any news on this? I would like to start with the extension.
-
6. Re: How to use CDI and before/after with UI tests?
bmajsak Jan 21, 2016 3:50 PM (in response to chschulz)Got stuck with other stuff :\ Sorry for that.
Give me few more days, I will share something on github. I don't want to point you to some bigger example (like in Arquillian Persistence Extension), as this might require getting a bit bigger context of the given extension.
-
7. Re: How to use CDI and before/after with UI tests?
mjobanek Jan 29, 2016 9:09 AM (in response to chschulz)Hi guys,
with the new version of the arquillian-core, there is one new possibility - to use a JUnit rule for that. see Arquillian Core 1.1.11.Final Released · Arquillian Blog
The rule will be launched on both the client side and in a container (depends on which method is going to be run).
-
8. Re: How to use CDI and before/after with UI tests?
chschulz Mar 2, 2016 5:48 AM (in response to mjobanek)Sounds great, but it seems that there is an issue with the warp extension, see NullPointerException in ProxyUsageTracker with Warp and recent version of Universe and using ExpectedException Rule.
Furthermore I am wondering how to write a JUnit rule which is only applied in the container during the before phase.
-
9. Re: How to use CDI and before/after with UI tests?
mjobanek Mar 17, 2016 11:38 AM (in response to chschulz)Looking at the dependency tree - there seems to be some older version...
-
10. Re: How to use CDI and before/after with UI tests?
chschulz Mar 21, 2016 8:10 AM (in response to mjobanek)Please answer in the other thread and tell me which dependency is older.
Furthermore I am wondering how to write a JUnit rule which is only applied in the container during the before phase.How to use CDI and before/after with UI tests?
Is there any annotation or similar to do this?
-
11. Re: How to use CDI and before/after with UI tests?
mjobanek Apr 6, 2016 8:19 AM (in response to chschulz)Answered... BTW, the exception should not have any impact on using @Rule in your tests (if you are using TestRule or MethodRule).
Yeah, you are right that you cannot force JUnit rule to be run only in the container - in the case of in-container test method it is run on both sides.
-
12. Re: How to use CDI and before/after with UI tests?
mjobanek Apr 12, 2016 5:06 AM (in response to mjobanek)Similar discussion: Re: JUnit Rules execution