To compare two projects for testing purpose, the test framework provides the com.nomagic.magicdraw.tests.common.comparators.ProjectsComparator class with the compare(Project, Project) method for comparing two projects (see the following figure). The default implementation of ProjectComparator can be created using the createProjectComparator(java.lang.String) 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 com.nomagic.magicdraw.tests.common.comparators.ModelComparator interface. Developers may exclude some model elements from the comparison by providing the custom com.nomagic.magicdraw.tests.common.comparators.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 com.nomagic.magicdraw.tests.common.comparators.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(java.io.File) 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.