MagicDraw 18.3 Documentation

Skip to end of metadata
Go to start of metadata

To compare two projects for testing purpose, the test framework provides the ProjectComparator class with the compare() method for comparing two projects (see the following figure). The default implementation of ProjectComparator can be created using the createProjectComparator() method of the MagicDrawTestCase class. Projects can be compared by checking their model elements and element symbols in diagrams for equality.

Project comparator provided by test framework

The model elements comparison can be configured using the ModelComparator interface. Developers may exclude some model elements from the comparison by providing the custom ModelComparatorFilter interface implementation. Please note that the default implementation of ProjectComparator does not compare the diagram information table, root model comment, and elements from used projects.

The default implementation of DiagramComparator compares diagrams for changes by analyzing a location and a size of the symbols presented in diagrams. The graphical differences of compared diagrams can be saved in the graphical PNG file using the saveDiffToImageFiles() method of the DiagramComparator interface.

Developers may create their own comparators for the custom diagrams and model elements comparison by implementing ModelComparator and DiagramComparator interfaces. The custom Model and Diagram comparators implementation can be set to ProjectComparator using appropriate setter methods.