## Examples Philosophy

JBehave was developed as behaviour-driven and example-driven. As such, examples are an integral part of the build, since they act as automated acceptance criteria verifying the correctness of the JBehave's behaviour. The examples are run as integration tests, complementing the behaviour verified by unit tests.

Examples could also be called Behaviours, as they represent integration-level behaviours.

## src/main or src/test?

A recurring question that is often asked is where one should place the behaviour code, in src/main or src/test. The answer is largely a matter of convention and depends on the build system you are using.

In Maven, src/test tends to be used for unit testing and anything found in the test directory is not packaged in the artifact being built. Also, src/test conventionally tests only the code contained in that module. This is why it is recommendable for integration testing to have a separate module and to place the behaviour code in src/main. This allows the integration testing module to verify the behaviour of multiple production modules and it also allows the modularisation of the integration testing itself.

That said, JBehave allows the running of stories from either src/main or src/test (the behaviour is controlled by the scope=[main|test] property of the Ant/Maven configuration). So it's down the the user preference where to place the behaviour code.

The examples modules contain a mix of stories/steps classes as well as other code used in the running of the examples. This code is functional to the testing and should be thought of as "test code". It constitutes a test harness that verifies the "production code" that is found in the JBehave core modules.