Integration test

Integration test

Integration test will be supported in next release (0.8 targeted for beginning of may).

Since the beginning of the project, easyant was already designed to have a dedicated phase to run integration test.
Until now, no plugin was contributing to this phase. This will change in next release, were the following plugins will be provide ready to use targets to run integration-test :
* junit plugin
* testng plugin
* antunit plugin

 

What are the differences between UnitTest and IntegrationTest ?

Usually people think that if they use Junit they do Unit Tests, but in reality the difference if more subtile. Let’s see in details the main differences.

UnitTests

In theory, UnitTest are supposed to test the method content but not a whole choreography. It should be a stand-alone test which is not related to other resources.
Example: If you’re writing unit test on your service layer, you’re service is probably calling classes from the data access layer. So the UnitTest should test only the service method and not the sub calls done by data access layer.

UnitTests are supposed to check internal workings of a class by testing portions of code (“units”). It specify and test one point of the contract of single method of a class. This should have a very narrow and well defined scope. Complex dependencies and interactions to the outside world are stubbed or mocked.
In the previous example we should “mock” the call to the data access layer.

The objective is simple, we want to be sure that :

  • the method (excluding all sub calls) do what it is supposed to do
  • evaluate the code coverage
  • have a robust code
  • unit test will run fast (a few seconds)

Usually tests are done by developers to enforce their code base.

IntegrationTest

In opposite, IntegrationTests are designed to check inter-operation of multiple subsystems (multiple units).
There is whole spectrum there, from testing integration between two classes, to testing integration with the production environment.
Integration test can :

  • validate that all pieces of code developed individually works together.
  • test the whole choreography of a given use case (business choreography, everything from the UI to the DB, inter-operation between applications, etc…)
  • validate the application as a functional point of view (usually called Acceptance Test) before a release
  • run UI tests (done by tools like selenium, sahi, etc…)

Comparing to UnitTests, IntegrationTest can be longer. Usually we should run integration-test on nightly builds or at least before each release.

How to manage this with easyant ?

EasyAnt will provide ready to use targets configured over conventions to handle separately UnitTests and IntegrationTests.
Here again even if we provides conventions, we never lock you in, so you can adapt this to your needs.

By convention :

  • UnitTest are stored in the src/test directory
  • IntegrationTest are stored in the src/integration test directory.

UnitTest

The directory structure of Unit Tests looks like this :

  • src/test/java : for test source code (note that this can be configured through the property src.test.java)
  • src/test/resources : for test resource files (note that this can be configured through the property src.test.resources)

Note: this also apply with non-java project (like groovy / scala project).
Groovy project :

  • src/test/groovy for test source code (note that this can be configured through the property src.test.groovy)

Scala project :

  • src/test/scala for test source code (note that this can be configured through the property src.test.scala)

Antunit :

  • src/test/antunit for antunit test (note that this can be configured through the property src.test.antunit)

IntegrationTest

The directory structure for integration test looks like this:

  • src/integration-test/java for integration test source code (note that this can be configured through the property src.test.integration.java)
  • src/integration-test/resources for integrationtest resource files (note that this can be configured through the property src.test.integration resources)

Note: this also apply with non-java project (like groovy / scala project).
Groovy project :

  • src/integration-test/groovy for integration test source code (note that this can be configured through the property src.test.integration.groovy)

Scala project :

  • src/integration-test/scala for integration test source code (note that this can be configured through the property src.test.integration.scala)

Antunit :

  • src/integration-test/antunit for antunit integration test (note that this can be configured through the property src.test.integration antunit)

Others :
You can also write your own plugin by following this guide.
Your plugin should provide a target bound to integration-test. This plugin will run test-scenario’s stored in your phase to run scenario stored in src/integration-test

Example: if you want to write your own selenium plugin you could run the scenario stored in src/integration-test/selenium

Comments are currently closed.