Skip to main content

Posts

Showing posts from April, 2012

Using the ShrinkWrap Maven Resolver for Arquillian Tests

This post assumes that you're familiar with using Arquillian for testing Java applications. If you’re not familiar with Arquillian, then I suggest you check out the guides at  http://www.arquillian.org/  where you’ll learn how to write Java tests that can run on the server and are much easier to write and maintain. When writing an Arquillian test, you create a deployment as in the following code sample: @Deployment public static Archive<?> createTestArchive() { return ShrinkWrap.create(JavaArchive.class, "test.jar") .addClasses(RandomNumberBean.class); } It’s not uncommon to see a lot of calls to .addClasses() or .addPackages(). When working with third party libraries, this list of classes/packages added to the archive can grow and grow (and can be a bit of a trial and error process to get a complete list of dependencies). The ShrinkWrap Maven Resolver overcomes this issue by allowing you to specify Maven dependencies in the createTestArchive() method rat...