<!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>Test Case Generation for Programming Language Metamodels</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, National University of Ireland</institution>
          ,
          <addr-line>Maynooth</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>for Software Language Engineering 2010 Doctoral Symposium</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>One of the central themes in software language engineering is the speci cation
of programming languages, and domain-speci c languages, using a metamodel.
This metamodel provides a greater degree of abstraction than a context-free
grammar, since it can ignore syntactic details. However, its main bene t is in
providing for the speci cation of the abstract syntax graph of a language, and
this can then be used for the construction or generation of language processing
tools.</p>
      <p>One problem associated with the use of programming language metamodels,
and metamodels in general, is determining whether or not they are correct. Of
course, one approach is to forward engineer code and test this, but it should
also be possible to test the metamodel directly. In this context, the question
addressed by our research is: given a programming language metamodel, how
can we generate an appropriate test suite to show that it is valid?</p>
      <p>Being able to generate such a test suite would have two main bene ts. First,
examining the automatically-generated test cases would help to develop the
modeller's understanding of the metamodel, and help to increase con dence in its
validity. Second, since the metamodel speci es a programming language, the
generated test cases should be valid programs from that language, and these can
be used as test inputs for tools that process the language.</p>
    </sec>
    <sec id="sec-2">
      <title>Related work</title>
      <p>
        Testing a programming language speci cations, at least at the syntactic level,
has a long history, dating back at least to the work of Purdom on generating test
cases from grammars [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. However, a naive application of Purdom's approach to
a programming language grammar produces programs that may not be
syntactically correct (since the grammar may under-specify), and is certainly unlikely
to produce semantically valid (let alone meaningful) programs [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
? This work is supported by a John &amp; Pat Hume Scholarship from NUI Maynooth.
      </p>
      <p>
        Incorporating at least a language's static semantics into test suite generation
must go beyond simple context-free grammars. One possible approach is to use
attribute grammars, and to seek to exploit the attribute equations to constrain
or even direct the generation of test cases [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ]. Despite this research, it is still
not a trivial task to directly extend this work to a metamodelling environment
that uses, for example, OCL-like constraints for describing the static semantics.
      </p>
      <p>
        It is possible to borrow some ideas from software modelling, and there is a
great deal of existing research dealing with model-based testing strategies [
        <xref ref-type="bibr" rid="ref5 ref6">5,
6</xref>
        ]. However, much of this work focuses on the behavioural elements of software
models (such as state machines), rather than the structural aspects which might
be more relevant to metamodelling.
      </p>
      <p>
        In the context of testing structural models, two tools strike us as being
particularly noteworthy:
{ USE (a UML-Based Speci cation Environment) which allows the user to
specify a UML (Uni ed Modeling Language) class diagram with OCL
constraints [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. From these we can manually generate corresponding object
diagrams, and the USE environment will check that these are valid instances,
satisfying the relevant class invariants.
{ Alloy which has its own logical speci cation language, corresponding roughly
to the elements found in a class diagram, and automatically generates object
diagrams that correspond to this speci cation [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. One of the useful aspects
of the Alloy tool is that it is designed to work with a number of di erent
SAT solvers in order to test constraints and generate counter-examples.
      </p>
      <p>
        As part of an earlier project, we have previously exploited the close
relationship between the Alloy notation and UML class diagrams to generate
instances of a metamodel for software metrics [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. One of the drawbacks of this
earlier approach is that it did not control the strategy used to generate instances.
Faced with the impossibility of manually validating several hundred thousand
instances, we exploited test-suite reduction techniques to narrow the set of test
cases.
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Proposed Solution</title>
      <p>It is clearly ine cient to generate test cases that are not used, and an ideal
solution would be to generate an appropriate set of test cases in the rst place. Of
course, this immediately raises two questions: what do we mean by an appropriate
set of test cases, and how do we generate these test cases?</p>
      <p>One way of measuring the adequacy of a set of test cases for a piece of
software is to use coverage criteria. Typically, a test suite can be judged in terms
of the percentage of statements, decisions, branches etc. in the source code that
are executed when the software is run. It seems natural therefore to attempt to
seek to assemble a test suite for a metamodel along similar lines, i.e. to form a
set of models that cover the features of the metamodel. In terms of programming
language metamodels, this would involve creating a set of programs that exercise
the features of the language.</p>
      <p>Since most metamodels, including programming language metamodels, are
described using UML, it is possible to use UML techniques to compute their
coverage. Many coverage criteria for the various UML diagrams have been
proposed [10{13]. However, we restrict our attention to UML structural diagrams,
since metamodels are often presented in the form of UML class diagrams.</p>
      <p>
        Our recent work has focused on coverage criteria for UML class diagrams
initially proposed by Andrews et al. [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], speci cally:
{ Generalisation coverage which describes how to measure inheritance
relationships.
{ Association-end multiplicity coverage which measures association
relationships de ned between classes.
{ Class attribute coverage which measures the set of representative attribute
value combinations in each instance of class.
      </p>
      <p>
        It is unlikely that these alone will provide su cient granularity to determine
the adequacy of a test suite, and previous work has already determined that
there is a poor correlation between coverage of syntactic and semantic features
[
        <xref ref-type="bibr" rid="ref15">15</xref>
        ]. However, our immediate work has centred on constructing an extensible,
modular system that can at least measure these levels of coverage, and which
can be used as a basis for further studies.
4
      </p>
    </sec>
    <sec id="sec-4">
      <title>Research Method</title>
      <p>Our research can be broken down into three phases:
Phase I: calculating coverage measures for programming language metamodels,
Phase II: generating valid models that satisfy coverage criteria,
Phase III: generating models satisfying criteria not based on coverage.</p>
      <p>
        In our work to date we have constructed a tool-chain which, when given a
UML class diagram and a set of UML object diagrams, will calculate the three
coverage measures described above [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ]. The tool chain uses the USE tool as
a parser and validator for the class and object diagrams, and uses the Eclipse
Modeling Framework (EMF) to represent these as instances of the UML
metamodel. To represent the output we have built a coverage metamodel in EMF
which is essentially an extension of an existing metrics metamodel [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ]. Finally,
we have written a transformation to calculate the coverage measures using ATL
(ATLAS Transformation Language).
      </p>
      <p>In order to complete the rst phase we intend to extend the coverage measures
for class diagrams to deal with the associated OCL constraints. We intend to
use (OCL) decision coverage as our initial measure, and to extend our tool chain
to implement this coverage.</p>
      <p>In the next phase, we hope to generate valid models that satisfy coverage
criteria for at least one programming language metamodel. We are currently
studying Alloy's approach as a model of exploiting third-party SAT solvers to
control model generation.</p>
      <p>At the nal phase of our research we hope to expand this approach to other
language-based criteria. To do this, we intend to use OCL-based queries across
the metamodel to specify the kind of model to be generated. Ideally, this would
allow a user to specify the kind of programs that would be generated in the test
suite for a given language metamodel.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Purdom</surname>
            ,
            <given-names>P.:</given-names>
          </string-name>
          <article-title>A sentence generator for testing parsers</article-title>
          .
          <source>BIT</source>
          <volume>12</volume>
          (
          <issue>3</issue>
          ) (
          <year>1972</year>
          )
          <volume>366</volume>
          {
          <fpage>375</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Malloy</surname>
            ,
            <given-names>B.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Power</surname>
            ,
            <given-names>J.F.</given-names>
          </string-name>
          :
          <article-title>An interpretation of Purdom's algorithm for automatic generation of test cases</article-title>
          .
          <source>In: 1st Annual International Conference on Computer and Information Science</source>
          , Orlando, Florida,
          <source>USA (October 3-5</source>
          <year>2001</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3. Lammel, R.:
          <article-title>Grammar testing</article-title>
          . In: Fundamental Approaches to Software Engineering. Volume 2029 of Lecture Notes in Computer Science., Springer Verlag (
          <year>2001</year>
          )
          <volume>201</volume>
          {
          <fpage>216</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. Lammel, R.,
          <string-name>
            <surname>Schulte</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          :
          <article-title>Controllable combinatorial coverage in grammar-based testing</article-title>
          .
          <source>In: 18th IFIP TC6/WG6.1 International Conference on Testing of Communicating Systems</source>
          , New York, NY (May
          <year>2006</year>
          )
          <volume>19</volume>
          {
          <fpage>38</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <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>August 2007</year>
          )
          <volume>892</volume>
          {
          <fpage>912</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <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="ref7">
        <mixed-citation>
          7.
          <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="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Jackson</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          : Software Abstractions. MIT Press (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <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,
          <source>Norway (April 9-11</source>
          <year>2008</year>
          )
          <volume>288</volume>
          {
          <fpage>297</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <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="ref11">
        <mixed-citation>
          11.
          <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="ref12">
        <mixed-citation>
          12.
          <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>
          (
          <article-title>4) (July/August</article-title>
          <year>2009</year>
          )
          <volume>253</volume>
          {
          <fpage>286</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <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="ref14">
        <mixed-citation>
          14.
          <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>
          ) (April/June 2003)
          <volume>95</volume>
          {
          <fpage>127</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Hennessy</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Power</surname>
            ,
            <given-names>J.F.</given-names>
          </string-name>
          :
          <article-title>Analysing the e ectiveness of rule-coverage as a reduction criterion for test suites of grammar-based software</article-title>
          .
          <source>Empirical Software Engineering</source>
          <volume>13</volume>
          (
          <issue>4</issue>
          ) (
          <year>August 2008</year>
          )
          <volume>343</volume>
          {
          <fpage>368</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Wu</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Monahan</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Power</surname>
            ,
            <given-names>J.F.</given-names>
          </string-name>
          :
          <article-title>Using ATL in a tool-chain to calculate coverage data for UML class diagrams</article-title>
          .
          <source>In: 2nd International Workshop on Model Transformation with ATL</source>
          , Malaga, Spain (
          <year>June 2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <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/#
          <source>UML22Measure (August 30</source>
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>