The quality of the specifications used for test generation plays an essential role in the quality of the generated tests. One approach to improve the quality of the UML specification is the use of executable models specified using the Foundational Subset for Executable UML Models (fUML) and the Action Language for fUML (Alf). Due to their precise semantics, fUML and Alf models can be simulated or executed using an fUML execution engine.

There are several fUML implementations, including the open-source fUML Reference Implementation and the Moka simulation engine for Papyrus, which is an open source Eclipse-based UML editing tool. fUML Activity Diagrams (ADs) containing Alf code can be executed and tested in Moka.

Model execution and testing allow one to examine and improve the functional correctness and the overall quality of models. However, one must provide input data required to reach and execute all essential elements in the graphical fUML and textual Alf models. Manual generation of input data might be suitable for small and simple models, but it is often not the case for complex real-life models. Similarly, test generation for executable models is a tedious and challenging task.

The work presented in this paper addresses two research questions:

  • How to automatically generate input data needed to simulate all execution paths in fUML ADs containing Alf code?
  • How to generate test cases with Oracle from fUML ADs containing Alf code?

To address these research questions, we present an approach for exhaustive simulation and test generation from fUML ADs containing Alf code. The proposed approach, called MATERA2-Alf Tester (M2-AT) (process depicted in the figure above), translates fUML ADs and associated Alf code into equivalent Java code and then automatically generates:

  • Input data needed to cover or execute all paths in the executable fUML and Alf models and
  • A test suite comprising of test cases and test oracle (expected output) for testing the actual implementation of the system under development.

The generated test cases in M2-AT satisfy 100% code coverage of the Java code. The generated input data is used for executing the original fUML and Alf models in the Moka simulation engine. The interactive execution in Moka allows one to determine model coverage of the executable models. Additionally, the generated Java code can be reused later on as a starting point for the actual implementation of the system. We also present our toolchain integrated with Papyrus and demonstrate our proposed approach with the help of an example. The full publication is accessible at Exhaustive Simulation and Test Generation Using fUML Activity Diagrams

Share This