Link to Colorado State University Home Page






Eclipse Plugin for Testing UML Designs (EPTUD)

EPTUD is a Eclipse plugin that allows UML model execution and testing. JUnit-like framework is also developed that helps writing and executing tests for UML models.

EPTUD Architecture


Testing Process

The activity diagram in above figure summarizes the testing process. Testing begins when a tester provides the UML design model under test (DUT) to the testing system and selects a set of test adequacy criteria.

A set of test cases that satisfies the criteria is generated. A test case is a tuple consisting of three components: a prefix, P, a sequence of system events, E, and an oracle, O. Before a test is performed, the system is in an initial configuration containing a set of objects that can create any valid configuration of the DUT. The prefix, P, is a sequence of system events, which are applied to the system in the initial configuration to move it to the configuration in which testing starts. Testing is performed by applying the sequence of events, E = < e_i: i=1 .. n >, to the system. Each system event is a call to an operation.

The oracle, O, defines the expected behavior of the system. An oracle is a sequence of tuples (o_i, e_i), where o_i is the OCL constraint to be satisfied by the runtime configuration after the system event, e_i, is executed.

The testing system transforms the DUT into an executable form, EDUT, which is a program that simulates the behaviors modeled in the DUT. The EDUT utilizes information from structural (class diagrams) and dynamic (activity diagrams) descriptions of the design to simulate modeled behavior. The EDUT contains two parts: a static structure representing the runtime configuration of the DUT, and a simulation engine. The simulation engine is generated from activity diagrams (JAL specifications). JAL is an action language used to specify actions in the activity diagram.

Test scaffolding is added to the EDUT to automate test execution and failure detection. The result is referred to as the testable form of the design, TDUT. Test scaffolding executes the test and detects failures. Executing tests includes creating the initial configuration and applying test inputs to the TDUT.


EPTUD Pacakge Diagram

Package diagram for the EPTUD is shown in above figure. The Ecore Parser parses the EMF class diagram (the DUT) and creates the instance of UML Metamodel. The USE Spec Generator reads the information in the metamodel and generates an input specification of the system for the USE tool. The Code Generation + Test Scaffolding generates TDUT from the metamodel instance.

All the Test Drivers extend a ModelTestCase class provided by the EPTUD JUnit Extension. The extension also provides interface to USE so that Test Drivers can validate configurations. The TDUT invokes the USE functionality to validate configurations and check various constraints.

Please note that the above package diagram does not show EPTUD packages related to the GUI of the plugin. Only the packages related to UML testing are shown here.
Top


Installation

We used following configuration for developing and testing our plugin: Also, we used Eclipse UML (Omondo) plugin V 1.2.1 to draw UML models.
  1. Download EPTUD Plugin from here.
  2. Extract the contents of the EPTUD.zip file and copy edu.colostate.cs.TUMS folder to the plugins folder under your Eclipse installation folder.
  3. (Re)Start the Eclipse. This should detect presence of the new EPTUD plugin and restart Eclipse.
  4. Right click on an .ecore file in your project and you should see a EPTUD context menu. If you do not find the menu refer to Troubleshoot below. If you do see the menu refer to Procedure to test for more information about testing models.
Top

Procedure to Test Models

EPTUD can execute UML models created as EMF Ecore models. There are many possibilities (direct Ecore editing using EMF's tree editor, Omondo's EclipseUML graphical editor, import from third party tool etc.) to create a class diagram for your system. EPTUD lets you specify i) OCL constraints on various model elements and ii) operation behavior using an action language called Java-like Action Language (JAL).

The information is used to generate a executable and testable form. A detailed procedure follows:

  1. Create an EMF class diagram for your system. EPTUD uses the generated .ecore file in subsequent steps. Class diagram and .ecore example
  2. Open the .ecore file in EMF's simple tree-based sample Ecore editor. Choose the file in the package explorer and right click. Choose Open As > Sample Ecore Model Editor from the context menu to open the file in the tree editor. EPTUD provides additional capabilities to the editor to let you specify constraints and operation behavior.
  3. Right click anywhwere within the tree view and choose EPTUD > Specify Invariants to input system OCL constraints. Menu example and Constraints input example.
  4. Collapse all the nodes of the tree to see attributes, operations and associations. Right click on a particular operation and choose EPTUD > Specify Behavior in JAL to input JAL specification. Menu example and JAL input example.

This completes a specification phase of the system. A testable form of the system can be generated from the specification and it can be used to write and execute tests. The testing phase of the system can be carried out as follows:

  1. In the left window of package explorer choose .ecore and right click. Choose EPTUD > Generate Testing Package. Example. This generates:
    i) A testable form of the model under testable_models.Project java package. Marked as 1 in this Example.
    ii) The USE specification Project.use under testable_models.Project package. Just above the mark 2 in this Example. Please refer to USE tool for more information about USE, and the integration of EPTUD and USE.
    iii) A JUnit-like framework for running tests under testable_models.Project.Framework package. Marked as 2 in this Example
    iv) A sample/example test driver under testable_models.Project.Tests package. Marked as 3 in this Example
  2. Writing test cases: Writing test cases for models is very similar to writing JUnit test cases for testing code. For basic information about JUnit please visit http://www.junit.org.
    One of the basic differences while writing test cases for models is that a test case a tester develops is extended from testable_models.Project.Framework.ModelTestCase instead of junit.framework.TestCase. The ModelTestCase class integrates the model execution engine and USE subsystem and also provides a tester with an additional assert - assertConformance, to check conformance of a particular run-time object configuration against original model (viz. class diagram and OCL invariants). A sample test case testable_models.Project.Tests.SampleTestCaseForModel is generated as part of testable_models.Project.Tests package.
    Please refer to Publications for details of the EPTUD framework which can help you test your models more effectively.
  3. Launching test runner: One of the generated framework classes testable_models.Project.Framework.ModelTestsRunner loads and runs tests written by the tester under package testable_models.Project.Tests. To run the program, the classpath should contain following .jar files: junit.jar, swt.jar that can be found in standard Eclipse plugins installation folders org.junit_XXX and org.eclipse.swt.XXX_YYYY/ws/XXX/ respectively and EPTUD.jar, USE.jar that can be found under edu.colostate.cs.TUMS or can be downloaded from Download EPTUD. Refer to a screenshot that shows the configuration required to run the ModelTestsRunner. The ModelTestsRunner uses SWT that requires library path to SWT library be specified. The SWT library can be found under org.eclipse.swt.XXX_YYYY/os/XXX/. Refer to a screenshot that shows an example.
  4. Running test cases: Once the testrunner is launched, it lists all the test case drivers written by the tester. You can choose and run a test driver one at a time. The list of drivers is shown in the left pane and the results are displayed in right pane. Example.
If you find some discrepancies / missing information / unexpected behavior please refer to Troubleshoot below or Contact us.
Top

Troubleshoot

  1. Plugin not installed correctly:
    In case you do not see any EPTUD menu items as described in Installation, please carefully check for following items:
    • Please check if you are using required version of Eclipse and EMF.
    • Is EMF installed properly? Please check if you can open and edit .ecore model files with Sample Ecore Model Editor. If not then you need to reinstall EMF.
    • Please check if you have following plugins installed: org.eclipse.ui, org.eclipse.core.resources, org.apache.xerces, org.eclipse.emf.ecore, org.eclipse.jdt.core. EPTUD depends on these plugins for carrying out various tasks.
  2. If EPTUD is installed correctly, but while generating test packages it throws Unknown java.lang.RuntimeException:
    Plase check what version of JDK you are using. EPTUD requires JDK 1.3 or higher.
  3. Can not run the ModelTestsRunner due to java.lang.NoClassDefFoundError exception:
    Most probably the required .jar files are not added to project classpath. To run the program, the classpath should contain following .jar files: junit.jar, swt.jar that can be found in standard Eclipse plugins installation folders org.junit_XXX and org.eclipse.swt.XXX_YYYY/ws/XXX/ respectively and EPTUD.jar, USE.jar that can be found under edu.colostate.cs.TUMS or can be downloaded from Download EPTUD.
    To add these files to your project Build / Class Path, right click on your project in the package explorer and choose Properties > Java Build Path > Libraries > Add External JARs. You can then navigate to your Eclipse plugin installation folder and choose appropriate folders as described in previous guideline. Repeat the procedure to add all four files.
    One can also specify these files as part of Classpath for the Run configuration of ModelTestsRunner.
    Refer to a screenshot that shows the configuration required to run the ModelTestsRunner.
  4. Can not run the ModelTetstRunner due to java.lang.UnsatisfiedLinkError exception:
    Most probably a path to SWT library is not specified. Note that this path has to be specified as an argument to Java VM in the run configuration for ModelTestsRunner. Please choose menu Run > Run > Java Application. Create a new configuration and under Arguments > VM arguments specify the SWT library path: -Djava.library.path="ECLPISE_HOME/plugins/org.eclipse.swt.XXX_YYYY/os/XXX/". Please replace XXX etc. with details appropriate for your Eclipse installation. Refer to a screenshot that shows an example.
If a problem you are facing when using EPTUD is not listed here or in case the problem persists please Contact Us with details of the problem and your platform configuration.
Top

Contact

We will like to hear from you! Please send your questions, concerns, comments, bug reports to: Dr. Sudipto Ghosh
Top

Last updated 12/31/2004. Back