Model-Driven Architecture
Model-Driven Architecture
Powerful new development technologies such as model-based code generation will overwhelm test teams that continue to create tests by hand. It's time for testers to put their own productivity into a higher gear. Harry Robinson tells you all about it in this week's column.
Anything that changes the development process is going to change the testing process before long-so occasionally it's good to look up from the quality emergency of the moment to see what's coming over the horizon. The newest contender for changing the world of development is an initiative called Model-Driven Architecture (MDA).
The details of MDA can be complex, but its goal is simple. Instead of writing all the code for an application, developers will design their solutions in the Unified Modeling Language (UML). These UML designs will automatically generate code that, with minimal customization, can be mapped onto many different platforms. There will, of course, be platform-specific issues to consider, but if successful, MDA promises to generate as big a boost in productivity as the move from machine language to compilers forty years ago. Model-based code generation will make software faster to create, to update, to port, and to deliver. And MDA is gaining followers. Some development groups, notably in engineering firms, are already generating 40 to 80 percent of their code with MDA. Personally, I'm happy if MDA makes our developer brethren more productive, but how will MDA affect testers?
Here's an image for you to consider. Think of development and testing as two people walking together down a road at a mutually agreeable pace. The developer writes code by hand, the tester writes tests by hand to exercise that code; and this arrangement works pretty well. But if MDA increases developer productivity substantially, it would be as if the developer now has a bicycle and can now move at a much greater speed. How should the tester respond? Here are some options, illustrated with the bicycling image from above:
If the tester continues writing test cases by hand at the usual pace, while the developer generates code automatically, the development work will outpace the testing. This results in poor quality releases. Bicycle translation: The tester gets left in the dust as the developer rides over the horizon.
If the hand-written tests prevent the developer from moving as quickly as the MDA technology will allow, developers will accuse the test team of holding the project back. Bicycle translation: The developer grumbles at having to ride the bike at a walking pace.
If the test team tries to write tests by hand fast enough to keep up with the productivity of the developers, the testers will burn out. Bicycle translation: The tester runs alongside the developer's bike for awhile before falling down exhausted in the dust.
Since development is using models to generate code, the testers decide to use models to generate tests. Test generation would provide the flexibility, power, and rapid response needed to keep pace with development. Bicycle translation: The tester hops onto a bicycle and keeps up with development. Fighting tire with tire so to speak.
The last option, generating tests, seems the most viable.
Putting Some Wheels under Testing
So, what would this world of test generation look like? It will look different from much of the software testing that happens today. Here are some examples of behaviors we would see:
As soon as development creates a UML model, testers review the model for ambiguities, completeness, and correspondence to the customer's wishes. And test creates its own version of the model that will generate tests for the system.
When development generates code; testers will generate tests to exercise that code. Likewise, when development makes a change to the UML model and regenerates the code, test will make a change to the test model and regenerate the tests.
As development deploys code to specific platforms, the test team generates tests that execute against those platforms.
I don't think test generation from models can ever be a complete solution. Just as there are trails where walking is more appropriate than biking, there will always be parts of a software system that are best tested by hand. What I am suggesting, however, is that much of the mundane work of both development and testing will be handled by machines. And this is a good thing: it means that testers can focus their efforts on the creative aspects of their jobs.
Strap on Your Training Wheels
In a test-generating world, tester activities will begin to look a lot like developer activities. And, the skills that testers need will begin to look a lot like the skills that developers need: abstraction, planning, and design. So, what should testers do to prepare? Consider upgrading your skills, especially in understanding the UML and model-based test-generation techniques. Even if you don't see your team needing test generation for awhile, it is certainly worth your time to take the technology for a test ride, or at least a spin around the block!
Suggestions for further reading
- Find out more about Model-Driven Architecture at www.omg.org/mda.
- Take a look at Bob Binder's book, "Testing Object-Oriented Systems: Models, Patterns, and Tools," especially Chapter 8 "A Tester's Guide to the UML"
- Check out the latest work in using UML for test generation:
- "Towards Model-Driven Testing"
http://www.upb.de/cs/ag-engels/Papers/2003/TACos03-Heckel-Lohmann.pdf. - "Using UML for Automatic Test Generation"
http://www.agedis.de/documents/d133_1/ASE2001.pdf. - And, finally, you can find out all about model-based test generation at www.model-based-testing.org.



Comments
#1 Submitted by Mark Dalgarno on Thu, 11/03/2005 - 12:44pm.
I don't intend to get into the various merits / demerits of MDA - or the likelihood of viable MDA tools emerging -but I would note that it's my experience that code generation is on the increase - as evidence see the increasing number of tools on www.codegeneration.net.Code generation is of particular use where multiple similar products are to be produced in a software product line. In such cases the investment in producing code generators can be spread over multiple products. There are many documented examples of successful product lines using this approach - see the SEI's Software product Line Hall of Fame for some examples.However, what many of these case studies mention, and what I think is the core point of the article, is that when development get the capability to produce multiple differing products very quickly the testing job can become much harder.Techniques to help this situation do exist. However testers need to get involved early on to ensure the testability of the generated development artefacts and the generators themselves. This could involve production of a parallel test generator system.
#2 Submitted by Mike Whittaker on Tue, 10/19/2004 - 2:49pm.
>>Why should anybody believe that this fad will be more successful than S-M was<<Back in 1997, the S-M techniques were successfully used in the toolset by Kennedy-Carter (www.kc.com), producing executable code from automatically verified models.But then UML came along and the benefits of S-M OOA/OOD were semingly forgotten, a great shame since the process had a great deal to offer, not least the fact that it provided a process blueprint...... unlike UML which in principle seems to be all things to all people, and pretty much ignores the benefits of a structured step-by-step approach.
#3 Submitted by James Thomson on Thu, 01/08/2004 - 12:47pm.
I just have to say that I am astonished if this is the first time many of you are hearing of MDA. The technology and application thereof have been around for at least 4 years, if not more, and it makes me pause with wonder to realize that the majority of testing is still written and executed by hand.
#4 Submitted by John Hammink on Wed, 01/07/2004 - 10:09am.
The bicycle analogy is valid, but I'd like to extend it a bit further: keeping up is like trying to keep up running with someone riding on the back of a SCUD missile. Translation: The tester drops from exhaustion way too soon anyway while the developer crashes and burns somewhere way out of reach in the next continent.Without modelling tests as a direct output with modelling architecture, the testing effort is largely doomed from the beginning. But what can one do? Testing has always lagged behind development both technologically and methodologically. To be honest, there's no question in my mind about the need for modelling tests, but I'd really like to learn more about the "how" of it; without a huge investment in a model-based tool. Where can I learn more about model-based test-generation techniques in sufficient detail? A tutorial with a *real* phony app perhaps?John Hammink
#5 Submitted by Elizabeth Knight on Tue, 10/07/2003 - 3:43am.
Hi, Harry. I ran into this concept recently in the form of ASML, and of course I'm having the 'yeah, but' response.- I confess I don't get why it's supposedly such a big deal that this approach has this 'extra benefit' of design review. Maybe I'm missing something, but I've always taken it for granted that design review is implicit in the generation of tests, not in any given test-generation method. Writing tests manually has always led to questioning assumptions, ambiguities and contradictions just so we can fill in 'Expected Result' and make our work meaningful. Is there something more that ASM test generation provides? I'd love to understand what and why but I just don't get why it's better to tell a test engine what to expect than tell a Word document.- would it be true that this might have the same return-on-effort ratios by type of test as traditional automation? I've noticed that a tool like Robot or Winrunner works better for the 'method' testers than the fiendishly inventive people who just see the test plan itself as an envelope to push. Likewise, doesn't the opacity of something like ASML cut your returns in this higher register? I know I test weird and fiendish because a) I can see at a glance what the 'vanilla' test covers so I know where the uncharted turf is, and b) I get bored with actually executing the 'vanilla' test. If some engine is doing that vanilla for me, where's the simplicity/boredom I rely on?- My first thought on hearing about it was 'you're going to need QA people to QA the QA if you do this'. It seems to me that when testers start programming their work, they're prone to all the same pitfalls and blind spots as programmers. . . the presentation I saw suggested that ASML gives you automatic coverage stats on the code, which I suppose would help, but I don't know if it tells you how deep your *complexity* is. I'd go home and fret about that, at least until I got to where I could diagnose it myself by looking at a page of ASML. - What worries me here is what kind of assumptions we set up in project teams by keeping pace with developers. Do we gain anything, or do we just shovel the problems under a carpet that even we might have trouble reaching under? In my own experience, 'It will take us four weeks to write a worthwhile test plan for this' has actually been one of the most useful ways of getting dev to cough up their specs and designs early in the process. It's not just that it does take us that long. It's also the fact that because PM and dev *expect* it to take us that long, they're cheerful about fixing design. As soon as they start expecting I can keep up with them, I start getting more opposition to anything that will slow them down. It's been a running struggle any time automation was mentioned; I can't see it evaporating here.Very interested nevertheless.
#6 Submitted by Peter Hantos on Wed, 10/01/2003 - 5:55pm.
I thought that the Schlaer-Mellor method was doing exactly this before the "invention" of UML, and quietly disappeared without any notable success in automated code generation. Why should anybody believe that this fad will be more successful than S-M was?
#7 Submitted by Violet Weed on Mon, 10/06/2003 - 11:27am.
>>>>>>>>>>>What you're describing is design inspection. ... It has not been easy to promote inspections at any phase in the SDLC.>>>>>>>>>>>>>I solved this 'problem' by creating a "Code Review / Modeling" QA Team. I setup the team within the Development Environment from developers who were burnt out and wanted to do something different. They reported to the Director of QA (me) but worked closely with the developers as they were developers. They were thus one-step removed from the other QA Teams who were outside of Development, doing gray & blackbox testing. After maturing the team structure, within 6 months, I moved the Code/Model Test Team back inside the QA Frame and then they cross-trained the other testers to do reviews of the UML cases. However, it is the developer-crossed-over-to-Testers who create these types of cases. This approach came out of my days as a developer (60s-80s) and then as Production Manager of CASE modelers, testers and programmers. As a long-time developer who still continues to upgrade her development skills through disciplined self-study, I think any kind of modeling technique for test cases design and hardening will work... if you use the right type of team members and steadfastly focus on the specs/design elements while creating high-level cases, then trickle down to lower-level cases, etc.
#8 Submitted by Scott Ranville on Wed, 09/17/2003 - 12:19pm.
For the last number of years I have been working with tool vendors to automate as much of the software design process as possible. When we first started, there was a number of nay-sayers that said that this has been attempted previously and that we would likewise fail miserably. I think that we have proven otherwise. Granted, some of this is still work in progress, but we have made significant strides forward.The first technology that we worked on was automatic code generation. Our goal was to be within 10% ROM/RAM/CPU execution time of an "average" programmer. We worked with a number of tool vendors and were able to improve the code efficiency of all these tools, the best of which was efficient enough for use within deeply embedded applications. In some cases, the autocode tools generated more efficient code than the hand code. In the end, some of our original nay-sayers came back to us to ask us to apply the autocode to their models because they were behind schedule and needed some quick help.The next two technologies that I took a deep dive into were automatic generation of unit test vectors and applying formal methods to the models. For the test vector generation, I introduced this technology into a major automotive company whose internal benchmarks indicated a 75% reduction in the time to generate the test vectors over the hand generated test vectors. The test vectors generated by the tool achieved 9% more branch coverage than the hand generated test vectors (69% vs 78%). This was for their first test case when they were still learning the tool. I recommended some additional automation to them and estimated that they may be able to achieve ~90% reduction in time. The tool vendor told me that another company did a larger benchmark and achieved this 90% reduction in time. If you have more interest in this, I have a paper accepted at the 2004 Embedded Systems Conference in San Francisco next March which talks about this technology and the tool that achieved these results. The paper also talks about some custom extensions to the tool that I created that will allow MCDC test vectors to be achieved.Within the last year, a number of companies have released formal methods tools as well. I am still learning how good these tools are, but one of them has identified some "major" errors in a pilot project. In this case, the company found the same error as the tool, but only after they burned out a motor during field testing. In a second example, a different tool helped the company identify a number of bugs in rather old, and really trusted legacy code. If you have interest in this technology and these tools, I have a paper accepted to the 2004 SAE conference in Detroit next March.I also have a paper accepted for this years DASC (Oct. in Indianapolis) conference that provides an overview of a number of software development automation tools. I describe some "complete" tool chain options and list off the price of each tool as well as a brief description of the features of each tool.All of the above is for models created in Matlab, but Matlab includes state machines as does UML. I am confident that these same results can be achieved from a UML model if the effort is placed into this particular modeling style.Thanks,Scott RanvilleThe Software Beretscottranville@interfold.comwww.interfold.com/scottranville
#9 Submitted by Yu. M. on Wed, 09/17/2003 - 12:04pm.
I do not believe that we (users of these new "UML to code" tools) need to develop and execute (automatically) a lot of test cases at all.Correct transformation of a UML model into code should be tested by a developer of this tool.In case of a mature tool we would get a lot of errors due to incorrect requirements and incorrect UML models. Automatically generated test cases are not able to catch these errors. They would report only that our incorrect model was correctly converted into code.In this case old fashion approach would work:- already discussed manual or automated verification of a UML model,- and testing against original requirements.
#10 Submitted by Kathy Murray on Wed, 09/17/2003 - 10:22am.
Hi Harry, I agree with you in theory, but have been continually disappointed by attempts to realize this vision with modeling tools. In the 90's I worked for a software company with a CASE tool that generated code using the OO methodologies (early UML) available at the time. This never took off. I also worked on an application that generated test cases from a state model (we actually met to discuss this several years back). This also never took off. I now work for a large retailer and have developed other methods to realize this vision. As far as test generation is concerned we generate automation scripts from an outline based testplan. This is easier for most people to review than a model and significant improves our ability to react to development changes. As an example, we maintain ~ 30 test plans as opposed to over 3,000 test scripts for a particular application. As far as code inspection is concerned, I've found that it is far more important to inspect the business requirements. If they are ambiguous, incomplete, or open to interpretation you start the project behind the eight ball. We're still working on improving that process, but the time to improve in this area would not have been available if we hadn't streamlined the test execution phase.
#11 Submitted by Andrew Raybould on Tue, 09/16/2003 - 11:32am.
Harry, I would be more excited by MDA if I hadn't already seen several generations of technology and methodology promising leaps in productivity; this particular one has been around before, in the guise of CASE, in the late 80s - early 90s. Nevertheless, everything you propose is a good idea, regardless of whether MDA amounts to anything. In fact, testing as you describe is independent of MDA and dependent on something else: for us to be able to inspect models and to create test cases from them, the elements and components of the model must have well-defined semantics, and this calls for approaches like design-by-contract.
#12 Submitted by Tek Wallah on Mon, 09/15/2003 - 9:51pm.
Generating usable tests directly from UML will happen right after generating workable code from UML happens i.e. never. The problem is that anyone who doesn't understand the problem well enough to write the code -- or tests -- doesn't understand it well enough to generate a correct model. The absolute last thing we need is wrong models being used to create wrong code, tested by wrong tests.
#13 Submitted by Gene Fellner on Mon, 09/15/2003 - 6:13pm.
"As soon as development creates a UML model, testers review the model for ambiguities, completeness and correspondence to the customer's wishes." .... What you're describing is design inspection. The entire process improvement community just fainted in amazement! It has not been easy to promote inspections at any phase in the SDLC. To have a new technology come along that facilitates design inspections at the same time it (theoretically) obviates the need for code inspections (because generated code is always free of defects ^_^) is too good to be true! .... We always envisioned "roving bands" of inspectors who had a particular aptitude for it and honed that skill by practicing it, and furthermore brought an outsider's perspective that would catch defects that someone too close to the project might miss. But we won't complain if the testers want to take on the role. At least the inspections are not to be performed by the people who create the designs, which is a satisfactory separation of duties. .... Now if only we could propagate this outburst of sanity one step backward and implement requirements inspections, the world would be nearly perfect. Requirements defects are the most difficult to detect in the later phases of the project, the most troublesome to encounter in production, and the most expensive to fix. .... But we'll be patient. This is a great start!