This quote succinctly summarises continuous integration (CI). But why is it so important, and how can it benefit your Force.com project?
CI resolves dependency issues
Each time code is committed to a source control repository, it is built and unit tested against the entire code base, ensuring developers are mindful that their commits can and often do cause existing tests to fail. CI can pick up dependency issues at build time – useful for local developer build processes where the IDE may not check issues such as module dependency and compilation.
This is particularly important in a Force.com build environment where code is not compiled or tested when saved to the Salesforce server. Indeed, without a continuous build environment, compilation and unit test failures are commonplace and seldom identified until the entire suite of tests are manually executed.
CI aids the development of better unit tests
Well written unit tests should cover every facet of the entity being tested, be that a trigger, class or component comprising multiple artefacts. The more often that tests are run, the more assured we can be about the stability of our code base. CI ensures that tests are run frequently giving real time alerting on test failures so that they may be resolved early.
CI represents a paradigm shift for many Force.com developers who come from less disciplined development backgrounds. Unit tests should never be simply about ensuring there is adequate code coverage; they must thoroughly test the code including boundary and exception testing. This in turn promotes a more modular approach to software design where tried and tested patterns and techniques can be used to create properly testable, reusable component services.
This article provides great insight into writing Apex unit tests for the Force.com platform. It’s worth noting, however, that the art of writing good unit tests is universal regardless of the deployment platform.
CI allows for test metrics and reporting
Continuous integration servers can be configured to provide test metrics and reporting. It’s possible to view the build history over time for a given branch of development. This can be used to pin-point problem areas and use that information to improve the build approach. At Myriad Minds, using our CI process leveraging SVN and Bamboo running from a hosted Altassian Jira Studio instance, we rely on key metrics such as Top 10 Most Failing Tests, Top 10 Longest to Fix Tests and Top 10 Longest Running Tests.
Test metrics are useful in a Force.com development project to discover which components are untested or lacking fully integrated tests. We can also target repeatedly failing tests and determine the cause of failure, allowing us to efficiently direct our refactoring efforts. We can assess the unit test coverage and the quality and coverage of commentary. We can even extend our tool in new and imaginative ways to provide metrics we might never have considered.
CI provides accountability
Continuous integration provides visibility into the development teams day-to-day activities, making developers accountable for committing good quality, fully tested code. A CI approach quickly identifies the stars in your development team and, conversely, those developers who might need closer mentoring. CI sharpens the craft of both developer individuals and the team as a whole.
References:
- Martin Fowler is an author and international speaker on software development, specialising in object-oriented analysis and design, UML, patterns, and agile software development methodologies, including extreme programming.
- How to write good unit tests – salesforce.com’s Developer Force wiki.
Blog