Doug Rosenberg, ICONIX
Tom O’Reilly, Sparx Systems
ICONIX and Sparx Systems have collaborated on the production
of a new Add-In that extends the functionality of Enterprise Architect to
support Design-Driven Testing (DDT). DDT
(also known as ICONIX Process for Test)
will be described more completely in an upcoming book by Doug Rosenberg and
Matt Stephens. This article describes
how to use the Agile/ICONIX add-in to drive test code from UML models.
Let’s consider a simple Login use case, which satisfies 3
We can automatically generate a Robustness Diagram using the
add-in, by selecting the use case and choosing the Agile/ICONIX add-in from the
The add-in creates a new Robustness diagram under the use
case in the Project Browser, and propagates the Requirements (if desired) onto
the Robustness Diagram.
In addition to propagating the Requirements, the add-in
creates a new Note on the Robustness diagram that is hot-linked to the use case
Having the Requirements on the Robustness diagram helps us
to make sure we haven’t forgotten any Requirements as we analyze the use case.
By analyzing our use case using the Robustness Analysis
technique, we’ve added a lot of information to the model that can be used to
drive the testing of the application. To
begin with, our add-in can automatically generate test cases for each
“controller” on the Robustness diagram.
We can also choose to generate test cases for our
In some organizations, the development team might own the
“controller tests” while an independent QA team might own the “requirement
tests”. We can also generate test cases
for messages on Sequence diagrams.
Once we’ve generated the test cases, we can add Scenarios
using Enterprise Architect’s “Testing View”.
In this example shown, we’re adding scenarios to the test case that
validates the format of a password. We
need to check that the password is of the required length, contains a mix of
alpha and numeric characters, and is a mix of upper and lower case.
We can easily generate test plan reports using Enterprise
Architect’s built-in report generation capability. So driving our testing activity
from the model is very straightforward.
Even if the add-in did nothing more than what’s been shown
so far, it would still be extremely useful.
But there’s significantly more capability ahead. Sparx Systems has developed automatic
Transforms between test cases and test classes. Transforms exist for widely used unit testing
frameworks JUnit (for Java) and NUnit (for .Net).
When we transform our test case using the ICONIX JUnit
transform, “setup()” and “tearDown()” methods are added automatically, and a
test method is created for each scenario.
This transformation, originally envisioned by Matt Stephens while we
were writing the book “Agile Development with ICONIX Process”,
and implemented by Sparx Systems, is the essence of the Design-Driven Testing
Once the test cases have been transformed to test classes,
they can be code-generated, using Enterprise Architect’s standard
NUnit test classes can be generated in a variety of
languages; the example shown is a JUnit test class, code generated in Java.
In addition to being useful during Requirements definition
and Analysis/Conceptual Design phases of a project, the Agile/ICONIX add-in
also delivers value when transitioning from the Analysis phase to Detailed
Design, by automatically generating skeleton Sequence diagrams from Robustness
The add-in automatically creates a new sequence diagram, and
brings a “hot-linked” note, and all Boundary and Entity objects from the
Robustness diagram onto the Sequence diagram.
Developers then complete the design of the use case on the Sequence
Once the Sequence diagram is completed, the Add-in is used
to generate unit tests from the messages on the Sequence Diagram. Note that “controllers” on Robustness
diagrams tend to reflect a slightly higher abstraction level than Sequence
messages; that is, a controller may be implemented as multiple messages on a
Using the DDT process, we have the flexibility to test
against Requirements, against Controllers (“logical functions”) and to do true
unit testing at the Sequence message level.
All of these abstraction levels should be verified by our testing.
Thus the Add-in delivers value during the Requirements,
Analysis, and Design phases of the lifecycle, and automates the process of
driving test plans and test code directly from the models.
The Agile/ICONIX add-in enables a systematic approach to
software development that drives tests from a UML-based design. The authors believe this approach offers
significant advantages over “Test-Driven Development”, where the “design” is
driven by unit-testing.