Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arquillian Run Modes

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:

  • You create an archive that only contains the components you want to integrate and test with
  • You stream this in-memory archive to an actual container (deploying it)
  • You run the archive as a test inside the container
  • You make an assertion about what will happen as a result of that test

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!

like image 390
IAmYourFaja Avatar asked Jun 29 '12 16:06

IAmYourFaja


People also ask

How does Arquillian work?

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.

How do you run an Arquillian test in eclipse?

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.


1 Answers

  • in-container: use for white box, integration testing
  • as-client: use for black box, functional testing

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.

like image 145
IAmYourFaja Avatar answered Nov 03 '22 18:11

IAmYourFaja