Tests can be run locally by the developer on his/her own machine or as part of an automated build process. This article covers the later scenario.
The term continuous integration is literally about making the automated build and integration process run continuously.
The power of the automated build running the automated tests lies in that the developers will get feedback faster. The tests can run automatically on every check-in in order to ensure that none of the functionalities were broken after changing the code.
The automated build process consists of build scripts, automated triggers, a CI server and build agents.
There are usually several build scripts for different purposes. The purpose of the build script can be continuous integration, nightly and deployment. The CI build script can contain unit tests that take short time to run to give fast feedback and this script gives the most important information in the quickest time so that developers can continue with their work. The nightly build script can contain the integration tests that need longer time to run and this script gives all the information which is why it is slower. Last but not least the deployment build script is used to deploy the new version to the environment. The script can run on every check-in, every hour, every night or when another script finished.
The CI server triggers the build script on certain events, provides the necessary context and data like source code, has the build history and a dashboard with current status of all builds. The triggers start a specific unit of work or build configuration. This configuration can have context, like source code and environment variables, and history with information about when it started and how long it took to finish. The build server can notify if the build breaks, for example by sending an email.
Examples of tools for build scripts: NAnt, MSBuild.
Examples of CI servers: Jenkins, TeamCity, Visual Studio Team Foundation Server.
Resource for this article
- The Art of Unit Testing, Roy Osherove
- Continuous delivery, Jez Humble and David Farley
- Continuous integration, Paul Duvali, Steve Matyas and Andrew Glover
- Beautiful Builds