<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Using ATL in a tool-chain to calculate coverage data for UML class diagrams</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Hao Wu?</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Rosemary Monahan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>James F. Power</string-name>
          <email>jpowerg@cs.nuim.ie</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, National University of Ireland</institution>
          ,
          <addr-line>Maynooth</addr-line>
        </aff>
      </contrib-group>
      <fpage>60</fpage>
      <lpage>64</lpage>
      <abstract>
        <p>In this paper we describe the use of ATL as part of a tool chain that calculates coverage measures for UML class diagrams. The tool chains uses the USE tool as a parser and validator for UML diagrams, and represents the diagrams internally using the EMF framework. ? This work is supported by a John &amp; Pat Hume Scholarship from NUI Maynooth.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Typically, test suites for source code can be measured in terms of their coverage
of code features, such as statement, condition or decision coverage. In the context
of Model Driven Engineering (MDE), a considerable body of research exists in
the area of model-based testing [
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ], and a number of coverage criteria have
been proposed for UML diagrams [3{7]. Such criteria can be used not only in
the evaluation of an existing test suite but also to guide the automatic generation
of test cases [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>
        In this paper we restrict our attention to structural speci cation, in
particular UML class diagrams. These have the unusual feature that their instances,
namely object diagrams, are explicitly available in UML, making it possible to
calculate coverage data entirely within the UML framework. In this context,
coverage calculation becomes a matter of quantifying these diagrams, and is thus
closely related to deriving metrics for models. While there have been a number
of di erent approaches to this problem, we limit ourselves to those based entirely
in an MDE framework, and distinguish three main types of approach:
I. De ne the metrics directly as queries over the UML diagram [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
II. De ne a transformation from the UML diagram to a measurement
metamodel [
        <xref ref-type="bibr" rid="ref10 ref9">9, 10</xref>
        ]
III. De ne a transformation from the UML diagram to a \measurable entities"
metamodel, and de ne the metrics as queries over this metamodel [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ].
      </p>
      <p>
        Of course many other variations are possible. A further elaboration of
approach III, not considered here, would be to represent the metric speci cations
themselves explicitly as a metamodel, following the UML22Measure approach
[
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
      <p>As a trivial example to distinguish approaches I-III, consider the task of
counting the number of classes in a UML class diagram. Following approach
I we would simply de ne an OCL query on the class diagram metamodel to
count and return the number of classes. Following approach II, we would de ne
a transformation that would count the classes, and its target metamodel would
be instantiated with the relevant name-value pair to represent the result. Finally,
following approach III, we would rst de ne a transformation to project the
relevant classes to a metamodel of measurable entities, and the metrics themselves
would be de ned as queries over that metamodel.</p>
      <p>
        We believe the third approach has a number of advantages. First, it clearly
separates the three steps of the measurement process, which, following Kuhne
[
        <xref ref-type="bibr" rid="ref13">13</xref>
        ], we identify as a projection of the relevant details, an abstraction on the
elements, and nally a translation to the numeric metric values. A second advantage
is that it separates the process of metric speci cation from the application of
the metrics tool, so that speci cation can be done independently, by mining the
metric de nitions and constructing an appropriate metamodel. A third
advantage is pragmatic: by assembling the measurable entities as a separate model,
comprehension and debugging of the measurement process is greatly facilitated.
      </p>
      <p>
        In this paper we describe the use of ATL (ATLAS Transformation Language)
in extending our previous work [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], based on approach III, to calculating
coverage data from UML class and object diagrams. We apply the same approach of
explicitly representing the measurable entities, and then calculating the coverage
data from this. As well as the advantages listed above, this is of even greater
importance for coverage measurement, since identifying which model entities have
been covered would be considered a vital part of any coverage report.
2
      </p>
      <p>
        Implementation
As a rst step to implement a coverage tool for UML class diagrams we have
implemented a tool-chain to calculate Generalisation (GN ) coverage [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], for any
class diagram and its corresponding object diagrams. The tool-chain ties together
three tools:
USE (a UML-Based Speci cation Environment) is a tool that used for
modelling and validating designs, and allows the user to create class and object
diagrams (as well as other UML diagrams), and can also evaluate OCL
constraints and expressions [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ].
      </p>
      <p>
        EMF (Eclipse Modeling Framework) is framework within the Eclipse IDE that
provides code generation and tool support for modelling and metamodelling.
ATL is a model transformation language that transforms models based on
OCLlike rules [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ].
      </p>
      <p>Figure 1 shows how USE, EMF and ATL are linked together in a tool-chain
to perform coverage calculations. The inputs to the tool chain are a class diagram
and one or more corresponding object diagrams, speci ed using the USE syntax.
The output is an XML le representing an instance of our coverage metamodel.</p>
      <p>Our tool-chain essentially uses the USE tool as a parser and validator for the
class and object diagrams. This seemed more e cient than using other UML
tools since USE is open-source, provides a good GUI to allow viewing of object
and class diagrams, and provides many more facilities than shown here, which
we hope to exploit in the future.</p>
      <p>We have modi ed the USE tool in two ways. First we have annotated the
USE Java source code that represents a UML metamodel, and used this as
input to EMF to generate a UML metamodel in ECore format. Second we have
implemented a visitor that walks an object diagram and generates the Java code
that, when compiled and run, instantiates our EMF metamodel.</p>
      <p>As shown in Figure 1, the output of the USE layer in our tool chain is a class
diagram and a corresponding object diagram, both represented as instances of
a corresponding ECore metamodel in EMF.
&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:org.nuim.lunar="http:///org/nuim/lunar.ecore"&gt;
&lt;instantiatedClass name="Dolphin"&gt;
&lt;generalisation src="Dolphin" dst="Aquatic" name="Dolphin"/&gt;
&lt;generalisation src="Aquatic" dst="Animal" name="Dolphin"/&gt;
&lt;generalisation src="Dolphin" dst="Mammal" name="Dolphin"/&gt;
&lt;generalisation src="Mammal" dst="Animal" name="Dolphin"/&gt;
&lt;GN Coverage count="4" maximum="10" value="0.4" accValue="0.4"/&gt;
&lt;/instantiatedClass&gt;
&lt;instantiatedClass name="Pig"&gt;
&lt;generalisation src="Pig" dst="Terrestrial" name="Pig"/&gt;
&lt;generalisation src="Terrestrial" dst="Animal" name="Pig"/&gt;
&lt;generalisation src="Pig" dst="Mammal" name="Pig"/&gt;
&lt;generalisation src="Mammal" dst="Animal" name="Pig"/&gt;
&lt;GN Coverage count="4" maximum="10" value="0.4" accValue="0.8"/&gt;
&lt;/instantiatedClass&gt;
&lt;instantiatedClass name="Trout"&gt;
&lt;generalisation src="Trout" dst="Aquatic" name="Trout"/&gt;
&lt;generalisation src="Aquatic" dst="Animal" name="Trout"/&gt;
&lt;generalisation src="Trout" dst="Fish" name="Trout"/&gt;
&lt;generalisation src="Fish" dst="Animal" name="Trout"/&gt;
&lt;GN Coverage count="4" maximum="10" value="0.4" accValue="1.0"/&gt;
&lt;/instantiatedClass&gt;
&lt;/xmi:XMI&gt;
In order to calculate the class model coverage data, a coverage metamodel shown
in Figure 2(a) has been designed and used as the target model for an ATL
transformation. The coverage metamodel contains a list of instantiated classes,
each of which may have zero or multiple generalisation links. Each instantiated
class stores relevant values in one GN Coverage. Then the ATL transformation
takes in the necessary data from the class and object diagrams, projects out the
countable entities, in this case generalisation links, abstracts to record instances
of these from the object diagram, and uses ATL rules to transform this to the
relevant coverage data.</p>
      <p>
        Figure 2(b) shows a UML class diagram, taken from an introductory text on
UML [17, pg 226]. This class diagram has 8 classes in total, with 10 generalisation
links between these classes. Thus, by the generalisation criterion proposed by
Andrews et al. [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], a test set ought to cover all 10 generalisation relationships.
      </p>
      <p>In fact, to calculate GN Coverage it is only necessary to consider whether
or not a given class has been instantiated at least once. For example, knowing
that the class P ig from Figure 2(b) has been instantiated allows us to conclude
that the four generalisation links between P ig and Animal have been covered.
Figure 3 shows an example of the XML coverage le that is output for an object
diagram containing at least one instantiation of Dolphin, P ig and T rout.
At present our tool chain is limited in functionality as it only calculates
generalisation coverage and a restricted version of association coverage. However,
we believe that as a prototype it demonstrates the feasibility of the approach.
We are currently working on an extension of the tool to handle other features
of UML class and object diagrams, and hope eventually to harness the OCL
constraints to assist in completing the coverage measures for class diagrams.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Pilskalnsa</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Andrews</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Knight</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ghosh</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          , France, R.:
          <source>Testing UML designs. Information and Software Technology</source>
          <volume>49</volume>
          (
          <issue>8</issue>
          ) (
          <year>2007</year>
          )
          <volume>892</volume>
          {
          <fpage>912</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Utting</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Legeard</surname>
          </string-name>
          , B., eds.: Practical
          <string-name>
            <surname>Model-Based Testing</surname>
          </string-name>
          .
          <source>Elsevier</source>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Andrews</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          , France,
          <string-name>
            <given-names>R.</given-names>
            ,
            <surname>Ghosh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            ,
            <surname>Craig</surname>
          </string-name>
          , G.:
          <article-title>Test adequacy criteria for UML design models</article-title>
          .
          <source>Soft. Test. Verif. &amp; Reliability</source>
          <volume>13</volume>
          (
          <issue>2</issue>
          ) (
          <year>2003</year>
          )
          <volume>95</volume>
          {
          <fpage>127</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>McQuillan</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Power</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>A survey of UML-based coverage criteria for software testing</article-title>
          .
          <source>Technical Report NUIM-CS-TR-2005-08</source>
          ,
          <string-name>
            <given-names>NUI</given-names>
            <surname>Maynooth</surname>
          </string-name>
          (
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Dinh-Trong</surname>
          </string-name>
          , T.T.,
          <string-name>
            <surname>Ghosh</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          , France, R.B.:
          <article-title>A systematic approach to generate inputs to test UML design models</article-title>
          .
          <source>In: 17th International Symposium on Software Reliability Engineering</source>
          , Raleigh,
          <string-name>
            <surname>NC</surname>
          </string-name>
          (
          <year>2006</year>
          )
          <volume>95</volume>
          {
          <fpage>104</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Mahdian</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Andrews</surname>
            ,
            <given-names>A.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pilskalns</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          :
          <article-title>Regression testing with UML software designs: a survey</article-title>
          .
          <source>J. of Software Maintenance and Evolution: Research and Practice</source>
          <volume>21</volume>
          (
          <issue>4</issue>
          ) (
          <year>2009</year>
          )
          <volume>253</volume>
          {
          <fpage>286</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Briand</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Labiche</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lin</surname>
            ,
            <given-names>Q.</given-names>
          </string-name>
          :
          <article-title>Improving the coverage criteria of UML state machines using data ow analysis</article-title>
          .
          <source>Soft. Test. Verif. &amp; Reliability</source>
          <volume>20</volume>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Baroni</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Braz</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Abreu</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          :
          <article-title>Using OCL to formalize object-oriented design metrics de nitions</article-title>
          . In: ECOOP Workshop on Quantative Approaches in ObjectOriented Software Engineering, Malaga, Spain (
          <year>2002</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Vepa</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bezivin</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bruneliere</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jouault</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          :
          <article-title>Measuring model repositories</article-title>
          . In: Model Size Metrics Workshop at the MoDELS/UML, Genoa, Italy (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10. OMG:
          <article-title>Architecture-driven modernization (ADM): Software metrics meta-model (SMM)</article-title>
          .
          <source>Beta Speci cation ptc/2009-03-03</source>
          , Object Management Group (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Mens</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lanza</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>A graph-based metamodel for object-oriented software metrics</article-title>
          .
          <source>Electronic Notes in Theoretical Computer Science</source>
          <volume>72</volume>
          (
          <issue>2</issue>
          ) (
          <year>2002</year>
          )
          <volume>57</volume>
          {
          <fpage>68</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Vepa</surname>
          </string-name>
          , E.:
          <article-title>ATL transformation example: UML2 to Measure</article-title>
          . Available on-line as http://www.eclipse.org/m2m/atl/atlTransformations/#UML22Measure (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13. Kuhne, T.:
          <article-title>Matters of (meta-)modeling</article-title>
          .
          <source>Software and System Modeling</source>
          <volume>5</volume>
          (
          <issue>4</issue>
          ) (
          <year>2006</year>
          )
          <volume>369</volume>
          {
          <fpage>385</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>McQuillan</surname>
            ,
            <given-names>J.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Power</surname>
            ,
            <given-names>J.F.</given-names>
          </string-name>
          :
          <article-title>A metamodel for the measurement of object-oriented systems: An analysis using Alloy</article-title>
          .
          <source>In: IEEE International Conference on Software Testing Veri cation and Validation</source>
          , Lillehammer, Norway (
          <year>2008</year>
          )
          <volume>288</volume>
          {
          <fpage>297</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Gogolla</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          , Buttner,
          <string-name>
            <given-names>F.</given-names>
            ,
            <surname>Richters</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.:</surname>
          </string-name>
          <article-title>USE: A UML-based speci cation environment for validating UML and OCL</article-title>
          . Sci. Comp. Prog.
          <volume>69</volume>
          (
          <issue>1-3</issue>
          ) (
          <year>2007</year>
          )
          <volume>27</volume>
          {
          <fpage>34</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Jouault</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Allilaire</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bezivin</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kurtev</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>ATL: A model transformation tool</article-title>
          . Sci. Comp. Prog.
          <volume>72</volume>
          (
          <issue>1-2</issue>
          ) (
          <year>2008</year>
          )
          <volume>31</volume>
          {
          <fpage>39</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>Oestereich</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Developing Software with UML: Object-oriented analysis and design in practice</article-title>
          . Addison-Wesley
          <string-name>
            <surname>Professional</surname>
          </string-name>
          (
          <year>1997</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>