I'm trying to wrap my head around Arquillian and am just not fundamentally understanding the difference between in-container
mode vs. as-client
mode.
My understanding is that, with Arquillian/ShrinkWrap:
So, from my perspective, everything just "feels" like it would always be in-container
, since the tests are always executing inside a container.
Please help me understand the differences between these two modes and what types of integration tests both modes are suited for. Bonus points for providing a concrete code example (and not the vague ones straight from the Reference Guide!) that explain why/how you run the tests in both modes. Thanks in advance!
Arquillian is an integration and functional testing platform that can be used for Java middleware testing. With the main goal of making integration (and functional) tests as simple to write as unit tests, it brings the tests to the runtime environment, freeing developers from managing the runtime from within the test.
In Eclipse, if I right-click on an Arquillian test file and select: Run as → JUnit Test, the test appears to ignore the "<arquillian. launch>jboss-managed</arquillian. launch>" of the surefire plugin. Running the test from command line Maven will work.
i.e., for UI/functional testing ("as" the role of a "client" using the app in production) use as-client
mode with @RunAsClient
. For true integration testing (testing dependencies between classes where you need internal "white box" knowledge about the app itself), using in-container
mode.
In both cases ShrinkWrap and Arquillian deploy your in-memory archive (JAR/WAR/EAR) directly to the configured container (via a JBoss-homegrown streaming protocol), however when tests are run in different modes they have different access to the container depending on the test mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With