Build Automation Series: Part 3 – Automated Testing

In the last post in this series we added dependency management to our build process.

In this post we add automated testing to our build.

Automated Testing

Previously we have already added JUnit 4.5 as a dependency. To support mocking/stubbing in testing we also add Mockito 1.7 to our ivy.xml file.

We update our build.xml file to have a test target that will execute all JUnit tests (using junit ank task) and generate a html report (using junitreport ant task) at the end. If any of the tests fail the build fails.

Qualities of a Good Build

So far we are saying that a good build is:

  1. Automated
    1. IDE Agnostic – build is performed by some build tool (like ant) and is not tied to any specific IDE (like Eclipse or intelliJ)
    2. Executable tests are run as part of the build.
  2. Repeatable
    1. Is capable of being build on different machines from source checked out from source control.
    2. Clean – this target returns the state of the project to what it was when checked out from source control
    3. Compile – this target is responsible for compiling all source code of the project in a consistent way.
    4. Executable tests are run in a repeatable manner with the same result achievable after each build.
  3. Flexible
    1. Dependencies are easily managed (easy to upgrade to newer version of dependency if need be)

Coming up

In the next post, we will add a build target responsible for building the project and creating a deliverable.

View the code

You can browse the code for this post online at http://code.google.com/p/build-automation-environment/source/browse/#svn/branches/build-automation-series-3.

The code can be checked out from svn following the instructions here http://code.google.com/p/build-automation-environment/source/checkout.

Advertisements

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: