//////////////////////
 * Copyright (c) 2007-2012, Niclas Hedhman. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied.
 * See the License for the specific language governing permissions
 * and limitations under the License.
//////////////////////

[[core-testsupport,TestSupport]]
= Core Test Support =

[devstatus]
--------------
source=core/testsupport/dev-status.xml
--------------

Zest™ comes with classes to help with testing. For general development, only a couple of classes are of interest as the
others are mostly for EntityStore and Index/Query SPI implementations. There is also some mocking support, to allow
some of Zest's unique aspects to be mocked, but since Zest™ is so flexible at a fine-granular level, we have found that
mocking is seldom, if ever, needed.

include::../../build/docs/buildinfo/artifact.txt[]

== Your First Testcase ==
In most cases, you will probably use the AbstractQi4jTest class to simplify starting a Zest™ test instance.

[snippet,java]
--------------
source=tutorials/hello/src/test/java/org/qi4j/tutorials/hello/HelloTest.java
tag=step1
--------------

This will do all the initialization of a Zest™ runtime instance and create a single layer with a single module in it.
What goes into that module is declared in the assembly() method;

[snippet,java]
--------------
source=tutorials/hello/src/test/java/org/qi4j/tutorials/hello/HelloTest.java
tag=step2
--------------

In this case we declare that we have a ValueComposite of type org.qi4j.tutorials.hello.Hello which looks like

[snippet,java]
--------------
source=tutorials/hello/src/main/java/org/qi4j/tutorials/hello/Hello.java
tag=body
--------------

The say() method will get the _phrase_ and _name_ from its internal state (the State interface is not magical, it could
be named anything).

And then we create the actual test;

[snippet,java]
--------------
source=tutorials/hello/src/test/java/org/qi4j/tutorials/hello/HelloTest.java
tag=step3
--------------

By using the prototypeFor() we can access the hidden, internal and very private state of the ValueComposite. Once the
value is created we can reach this directly.

