PCM Development/Testing

Aus SDQ-Wiki

This site provides an initial overview of testing palladio extensions, including the general process and best practices.

General Process

  • Make sure that you adhere to the required project structure. For projects that are add-ons of the PCM core code, use the project template [1] to create an eclipse project stub for Palladio. See [2] for more details. For projects providing eclipse-based functionality, use the project template from [3]. Both project templates generate an initial project structure that contains the subfolder "tests" in which all test projects must be located. Note that the project templates also generate build artefacts for an automated build pipeline. Thus, all test projects included in the test directory are automatically tested during the build process.
  • Naming convention: Each Plugin project should have an equivalent test project, i.e. for the plugin project org.palladiosimulator.xyz there should be a project with the corresponding test code that follows the following convention: org.palladiosimulator.xyz.tests.
  • It is desirable to have fine-grained unit test for each part of the code to maintain high test coverage and to ensure consistency of the code in terms of refactorings or extensions. If this can not be guaranteed, coarse-grained unit tests for the use of the API must be written so that at least the high-level concepts of the extension is tested and documented.
  • More detailed information in Slides about testing from Developer Meeting 2020

Best Practices

There are a bunch of projects that support the writing of test cases. This sections provides a brief overview.

Standalone test initialization

Since all Palladio extensions have ecore dependencies, unit tests are hard to execute in a standalone-manner. Usually it is required when executing them in Eclipse to run them as a Plugin-Test. The standalone initializer project [4] can be used to execute them as normal JUnit tests.

Testing OCL constraints

In order to test specific OCL constraints for a given metamodel, have a look at [5] which provides an code example for an OCL-based test case. It is planned, to extract the code in a common test framework in order to provide a test infrastructure and to facilitate reuse.

Creating PCM test models

For the creation of PCM test models, the project [6] provides a fluent api model generator. The model generator offers a convenient possibility to create PCM test models in a fast and simplified way.

Examples