Feeds

Designing software for testability

You know it makes sense

Top 5 reasons to deploy VMware with Tegile

The subject of testing seems to be in the air at the moment - Matt Stephens recently discussed it in his "Agile" column entitled "Don't unit test GUIs". This month in the Java column we are also going to look at testing, but this time from the viewpoint of design.

Software design, in some ways, is a particularly strange art. The design itself is not a physical thing, it is not the artefact that will eventually be run nor is it any more concrete (in the sense of the real world) than the actual software that will be executed. Yet it is key to the successful production of effective software. It is also the step that will determine the overall structure, nature, and approach of the resulting software. Herein, of course, lies one of the ironies of the software development world – you can't test a design (at least not directly).

However, this does not mean that testing isn't relevant for design activities. Indeed, I would argue that testing is as important a consideration during design as it is during coding. It is certainly no less important than any other requirement that needs to be considered during any design steps.

In this column I am going to present two aspects to the consideration of testing that need to be considered during any design process. These are "design for testability" and "test first design".

Design for testability

Given any set of requirements, different designers may come out with markedly different designs. These designs will then form the blueprint of the way in which the software will be built, deployed, and executed. It is not necessarily true that one design is better per se than another, but it may certainly be true that one design is easier to implement, maintain, deploy and test than another. It is this last point that I want to consider here. That is: "How easy is a design to test once implemented in a language such as Java?"

It is certainly possible to design software in such a way as to make testing easier. The easier software is to test, the more likely it is to be tested. Certainly, in my experience, if software is hard to configure, set up and to actually test then less testing gets done. If software is easier to test more testing is likely to be performed and a greater number of flaws may be discovered.

As an example, consider the Java application presented below. As can be seen from this diagram we have a simple stateful session bean (using EJB 2.0) that provides a calculator-like function. However, to test the "business logic" of this bean we will need to either compile the classes, create appropriate XML files, jar these up with the classes, and deploy to an EJB container such as JBOSS or possibly OpenEJB (which can provide a lightweight test environment). We will then need to create a client class that uses an initial context and an EJB Home object to access the remote bean object. Only then can we test the business logic.


Figure 1: Standard stateless EJB design

However, we may all put off testing the business logic because we do not have a tool such as JBOSS or OpenEJB installed – and certainly the mantra of "test often and little" might well be forgotten.

Choosing a cloud hosting partner with confidence

Next page: Test first design

More from The Register

next story
That dreaded syncing feeling: Will Microsoft EVER fix OneDrive?
Microsoft's long history of broken Windows sync
Bada-Bing! Mozilla flips Firefox to YAHOO! for search
Microsoft system will be the default for browser in US until 2020
Mozilla, EFF, Cisco back free-as-in-FREE-BEER SSL cert authority
Let’s Encrypt to give HTTPS-everywhere a boost in 2015
SLURP! Flick your TONGUE around our LOLLIPOP – Google
Android 5 is coming – IF you're lucky enough to have the right gadget
Be real, Apple: In-app goodie grab games AREN'T FREE – EU
Cupertino stands down after Euro legal threats
Microsoft: Your Linux Docker containers are now OURS to command
New tool lets admins wrangle Linux apps from Windows
Facebook, working on Facebook at Work, works on Facebook. At Work
You don't want your cat or drunk pics at the office
prev story

Whitepapers

Choosing cloud Backup services
Demystify how you can address your data protection needs in your small- to medium-sized business and select the best online backup service to meet your needs.
Getting started with customer-focused identity management
Learn why identity is a fundamental requirement to digital growth, and how without it there is no way to identify and engage customers in a meaningful way.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
Security and trust: The backbone of doing business over the internet
Explores the current state of website security and the contributions Symantec is making to help organizations protect critical data and build trust with customers.
Storage capacity and performance optimization at Mizuno USA
Mizuno USA turn to Tegile storage technology to solve both their SAN and backup issues.