Showing posts with label Testing. Show all posts
Showing posts with label Testing. Show all posts

Wednesday, November 01, 2006

Writing tests in development

I recall on a number of previous projects that there was always some confusion around the type of tests that were written in development; that is, unit tests, integration tests, component tests, system tests, etc.. Of interest, then, I recently read this article from IBM developer works (a truly interesting RSS feed for those in Java software engineering).

Basically, it states that tests need to be categorised into:

  1. unit tests: single-class driven tests; isolating a piece of functionality (hopefully only one public interface per class!)
  2. component tests: multiple-class driven tests; often including core pieces of logic and functionality
  3. system tests: end-to-end testing; high-level, arbitrary logic executed; does the application work?
Importantly, it defines that the time taken for each category will increase significantly and therefore there should be multiple build / test loops with their own individual reports. So the unit testing which is used everyday is not corrupted by the component testing (e.g. driven by test defects) or system testing (e.g. driven by releases).

Saturday, October 21, 2006

3 mantras of modern day software development

Ok, I have been an avid reader of 43 folders for a while now. This week, however, they published a 3-part article on 'getting things done - software development' - and I thought that I would reiterate these mantras, how to apply with modern-day tools and discuss what happens if they are not applied.

So what are the 3 mantras: test, refactor, document! Ok, a caveat to these mantras, this should only be followed if you want to maintain (and improve) an application for more than a year, but if you don't want to do this, what sort of business case do you have?!

  1. TEST: despite overwhelming industry material over the last few years about the advantages of unit testing, there still seem to be a significant number of projects that do not enforce unit testing. The advantages are clear, unit testing enhances design (e.g. that there should be only one public API per class), enhances quality (e.g. combined with a coverage tool, all branches of logic are run, and verified in terms of expected behaviour), and most importantly this provides a baseline for the application's operation and maintenance. So, with a complete set of unit tests (i.e. coverage greater than 90%), any change to the underlying code base can be made by anyone because if the existing functionality is compromised a unit test will break. Therefore, immediately new developers are able to confidently make changes to the application, regardless of the size or complexity. In Java, one needs to look no further than JUnit, TestNG, etc..
  2. REFACTOR: refactoring is the ability for developers to change, rework, and enhance any exisiting code from an application that is required. Why? well this enables applications to be modernised and for existing, or more importantly future flaws to be corrected and countered. Not every line of code is written at the same quality as every other line of code (due to poor requirements, inexperience, poor implementation, etc.), with refactoring (as long as it is controlled) then the application's code base is continually being refined and in conjunction with unit tests, provides a robust, modifiable approach to maintaining application longetivity. A prerequisite for refactoring a featured IDE - and IntelliJ 6.0 cannot be beaten in this regard.
  3. DOCUMENTATION: probaly the most controversial; I used to think that unit tests alone could document an application, but in order to capture the brainstorming, design sessions, implementation decisions made in developing an application than some form of documentation is needed. I am a firm believer that all documentation related to an application: namely arhcitecture, requirements, design sessions, implementation, and maintenance should be held in a wiki with the condition that it has Google-like search features. To this end, Confluence must be the only option, and I see it as almost standard to any software development.
Without these approaches, I would foresee significant difficulty in maintaining any application.