If you have some experience with integration testing and functional testing on a Java virtual machine (JVM), John D. Ament’s important new book can help you get up to speed with the Arquillian testing platform’s numerous features and capabilities.
Arquillian “leverages JUnit and TestNG to execute test cases against a Java container,” Ament explains. The Arquillian framework, he adds, has three major sections: “test runners (JUnit or TestNG), containers (Weld, OpenWebBeans, Tomcat, GlassFish, and so on), and test enrichers (integration of your test case into the container that your code is running in.)” Also: “ShrinkWrap is an external dependency for you to use with Arquillian; they are almost sibling projects. ShrinkWrap helps you define your deployments, and your descriptors to be loaded to the Java container you are testing against.”
Ament’s 224-page book shows how to write simple code for various Java application tests but also explains how to develop rich test cases that you can run automatically.
The author uses the JUnit test container in his examples but explains how you can use the TestNG test container, if you prefer.
While the book is aimed at readers with intermediate experience, newcomers to Java testing can learn from it, too. Before diving into the process of explaining Arquillian, Ament describes “the fundamentals of a test case,” from an Arquillian perspective, of course. And he devotes a chapter to “The Evolution of Testing,” from the early days of manually testing single units to the advent of automated testing with powerful new tools. (Manual testing, by the way, is still important and will not go away soon, Ament indicates. “There is likely no removing manual testing for functional applications,” he writes.
“Manual testing should be considered when performing user acceptance testing, where you need to validate that the application functions the way you would expect end to end. From a quality assurance standpoint, it’s the most direct way to make sure an application works the way expected.” But, he warns, “a developer shouldn’t wait until this point to begin testing….”
He also devotes a chapter to the basics and the process of container testing. “Arquilian is all about testing your code inside a container,” he says. “Containers represent what your application will run on.” His text examines each of the “three primary ways that Arquillian can interact with a container — embedded, managed, and remote.”
Embedded containers, he notes, “typically run on the same JVM as your test case. Next are managed containers, which Arquillian will start up for you during the test process and shut down after the tests are run but run in a different JVM. Finally, there are remote containers, which are assumed to be running prior to the test and will simply have deployments sent and tests executed.”
The book’s remaining chapters take the reader deeper into the testing processes and how to use of Arquillian’s features and extensions.
Arquillian is not software you can learn to use effectively in a single weekend of hacking. You must learn it by using it and using it a lot, Ament emphasizes. “Run as many tests as you can with Arquillian…[y]ou make the best use of Arquillian when you use it throughout 100 percent of your tests.”
— Si Dunn