During usage of Arquillian I figured out some things that could be a starting point for best practices when testing with Arquillian.
In my application I had some defaults that I have to do every time, when I would like to implement a new test.
- Add logging
- Add persistence.xml
- For different domains, add all classes that belongs to the entity graph
- Setting up the name of the web-archive properly
- Introduces maven dependency lookup
In my opinion, it’s very handy to implement a helper class with the builder pattern, that creates
- a ShrinkWrap of type WebArchive with the given name
- has methods that fulfills the above requirements.
The impact on our testclasses was tremendous, we improved the readability and reduces the code duplication.
So long story short:
Introduce archive builder that encapsulates common patterns and combination of classes.