Book Image

Arquillian Testing Guide

By : John D. Ament
Book Image

Arquillian Testing Guide

By: John D. Ament

Overview of this book

<p>Integration testing sometimes involves writing complex codes. This book introduces you to the capabilities of Arquillian to enable you to write simple code with a broad range of integration tests for java applications. <br /><br />Arquillian Testing Guide serves as an introductory book to writing simple codes for testing java applications. This book will help you to develop richer test cases which can be run automatically while performing rigorous testing of the software. <br /><br />Arquillian Testing Guide introduces you to Arquillians features and capabilities. This book will help you understand the mechanism of creating deployments and test against those deployments. The book begins with basic JUnit test cases beginning with an enterprise test case, which then go on to discuss remote testing. During the course of the book, you will also learn how to mix container and non-container tests into a single test case. By the end of the book, you will have learned how to extend JUnit tests to work with Arquillian and deploy them to a container automatically.</p>
Table of Contents (17 chapters)

The transaction extension


Formerly, transaction support was built into the persistence extension. It's now considered as a separate extension from persistence to allow other tools to use it. One case may be if you want to test out a JMS message queue using transactions from your test case.

By default, when you add it to your classpath and run a persistence-based test, transaction support will be enabled. It should be a safe assumption that any extension would also load transaction support when needed, as long as it's on the classpath. If desired, you can tweak the transaction support in your test cases (note that this only applies to your test classes; EJBs and CDI beans behave as is when deployed to the application server).

The API for the transaction extension is simply an enum and an annotation. Adding @Transactional to your test case will turn on the transaction support. Setting the transaction mode attribute will control some aspects of the test. The default behavior is to commit after...