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)

Spock, very groovy test writing


Spock is a specification-oriented testing framework where your tests are written in a requirements-oriented way. The test cases are written in Groovy, but also use a JUnit test-case runner to execute the test case. Spock uses datasets to drive the test cases. Spock does things based on Behavior-driven development (BDD) to create test cases.

Spock uses specifications to define test cases, which will fail until the requirement is implemented. We can use Spock with Arquillian to execute deployments and run test cases against server-side code.

Let's suppose we have the following requirement:

Certain objects may have a state. States that these objects have can progress from 1 to 5. If one of these objects has state less than 1, then set its state to 1; also, if the state is greater than 5, set its state to 1. The server will expose the code that progresses the state of these objects, which will be sequential from 1 to 5.

From a design standpoint, we make a few assumptions...