This topic covers the Diff tool, which compares saved data with incoming data and reports differences in SOAtest and Virtualize.
With support for Binary, Text, XML, and JSON, the Diff tool is the current backbone of a best-practices regression testing solution.The Diff tool compares the data in its editor against the data that it receives from another tool's output or from another input that you specify and reports a failure when it finds a difference.
The Diff Project Configuration panel is divided into two main sections. The upper section contains general options. The bottom section contains the Regression Control, Ignored Differences, and Options tabs in which you can configure the options for Text, Binary, and XML comparisons.
To customize the logic and data source usage for all Diff regression controls in a test suite:
|
When Binary is selected from the Diff Mode drop-down menu of the Diff tool, the following options are available:
Data Source: Specifies the Data Source to be used for providing control values. This menu is only available if a Data Source was added to the project.For more information on Data Sources, see Parameterizing Tests with Data Sources, Variables, or Values from Other Tests.
Regression Control Source: Determines what data source values, file, or text is used as the "control" value (the value against which it will compare all subsequent results).
Editor: Choose this option from the drop-down menu and enter text you want to use as a regression control in the related field.
File: Choose this option from the drop-down menu and specify a file to use as a regression control. If you want to ensure that this file's path is always relative to your project file, enable the Persist as Relative Path option.
Data Source Column: Choose this option from the drop-down menu and specify a value from the designated data source column as regression controls. This option is only available if your project includes a data source.
When Text is selected from the Diff Mode drop-down menu of the Diff tool, the Regression Controls, Ignored Differences, and Options tabs are available:
The following options are available in the Regression Control tab of the Diff tool for Text mode.
Data Source: Specifies the Data Source to be used for providing control values. This menu is only available if a Data Source was added to the project. For more information on Data Sources, see Parameterizing Tests with Data Sources, Variables, or Values from Other Tests.
Regression Control Source: Determines what data source values, file, or text is usedas the "control" value (the value against which it will compare all subsequent results).
Editor: Choose this option from the drop-down menu and enter text you want to use as a regression control in the related field.
File: Choose this option from the drop-down menu and specify a file to use as a regression control. If you want to ensure that this file's path is always relative to your project file, enable the Persist as Relative Path option.
Data Source Column: Choose this option from the drop-down menu and specify a value from the designated data source column as regression controls. This option is only available if your project includes a data source.
From the Ignored Differences tab of the Diff tool for Text mode, you can delete any ignored text differences by clicking the Delete button
The following options are available in the Options tab of the Diff tool for Text mode.
Java[a-zA-Z ]+\Q(\E[4-9]+th Edition\Q)\E
When XML is selected from the Diff Mode drop-down menu of the Diff tool, the Regression Controls, Ignored Differences, and Options tabs are available.
XML Mode parses XML files, then compares them element by element and attribute by attribute (ignor-ing “ignorable” whitespace). The result of the comparison is expressed as an XML document. If you want to use this mode, make sure that both inputs are well-formed XML documents which have the same type of document element. The XML Mode provides three different graphical representations to configure XML messages:
The following options are available in the Regression Control tab of the Diff tool for Literal XML mode.
Data Source: Specifies the Data Source to be used for providing control values. This menu is only available if a Data Source was added to the project.For more information on Data Sources, see Parameterizing Tests with Data Sources, Variables, or Values from Other Tests.
Regression Control Source: Determines what data source values, file, or text is used as the "control" value (the value against which it will compare all subsequent results).
Editor: Choose this option from the drop-down menu and enter text you want to use as a regression control in the related field.
File: Choose this option from the drop-down menu and specify a file to use as a regression control. If you want to ensure that this file's path is always relative to your project file, enable the Persist as Relative Path option.
Data Source Column: Choose this option from the drop-down menu and specify a value from the designated data source column as regression controls. This option is only available if your project includes a data source.
When Form XML is selected as the Diff mode, the options in the Regression Control tab are divided into two sections: the XML View Tree and the XML Configuration Tabs.
The XML View Tree displays the literal XML as a tree, with each tree node representing an element. The options for the XML View Tree in the Diff panel can be configured in the same fashion as the Form XML SOAP Envelope options of the SOAP Client tool. For more information, see Manipulating the XML View Tree.
The XML Configuration Tabs allow you to add, remove, and rename XML components. The options for the XML Configuration Tabs can be configured in the same fashion as the Form XML SOAP Envelope options of the SOAP Client tool. For more information, see Manipulating the XML Configuration Tabs.
The SOAP Response mode compares values that you define to the actual outcome of the SOAP response. It allows you to compare multiple elements and attributes of the most complex XML structures.
Depending on the method, a number of different options may be available. The options for the SOAP Response mode can be configured in the same fashion as the Literal Value options of the SOAP Client tool. For more information, see Specifying Literal Values.
From the Ignored Differences tab of the Diff tool for XML mode, you can Add and Modify XPath settings by clicking the appropriate buttons. For more information on configuring Ignored Differences, see Understanding XPaths.
The following options are available in the Options tab of the Diff tool for XML mode.
ExamXML is a 3rd party tool that is licensed and purchased separately from A7Soft. If you select ExamXML MDCXML, be sure to specify the location of the executable and options file.
Notes:
The options file needs to contain the following minimum settings (using different values for the following parameters is not supported):
It is possible to create external regression controls automatically (save the expected content into files instead of embedding it in the Diff tool) as described in Configuring Regression Testing.
VMTools is built in to the product. No additional license is needed. If you select VMTools, you can specify the following options:
Output results as XML: Determines the diff output format. If this box is unselected, the output will display in table form. If this box is selected, the output will display in XML. Differences are only reflected when another tool is chained to the message output of the Diff tool.
Under certain conditions, VMTools will fall back to a text-based diff. This can happen if the XML is very complex and produces an excessive number of differences or would take an excessive amount of time to complete.
If this occurs, one of the following message will be printed to the Console view to explain what happened.
Did not run XML Diff, there are too many differences. Performing text mode diffing instead.
Did not run XML Diff, it did not finish within 30.0 secs. Performing text mode diffing instead.
The maximum time allowed to perform an XML diff before switching to text mode is the default timeout value specified in the preference panel’s Misc tab (Connection Settings> Default timeout)—but no higher than 120 seconds.
When JSON is selected from the Diff Mode drop-down menu of the Diff tool, the Regression Controls, and Ignored Differences are available.
The following options are available in the Regression Control tab of the Diff tool for JSON mode.
Data Source: Specifies the Data Source to be used for providing control values. This menu is only available if a Data Source was added to the project. For more information on Data Sources, see Parameterizing Tests with Data Sources, Variables, or Values from Other Tests.
Regression Control Source: Determines what data source values, file, or text is used as the "control" value (the value against which it will compare all subsequent results).
Editor: Choose this option from the drop-down menu and enter text you want to use as a regression control in the related field.
File: Choose this option from the drop-down menu and specify a file to use as a regression control. If you want to ensure that this file's path is always relative to your project file, enable the Persist as Relative Path option.
Data Source Column: Choose this option from the drop-down menu and specify a value from the designated data source column as regression controls. This option is only available if your project includes a data source.
From the Ignored Differences tab of the Diff tool for JSON mode, you can Add and Delete XPath settings by clicking the appropriate buttons.
When the Diff tool is configured in the XML mode, any differences found between the actual value and the expected value are expressed in XPath. XPaths represent the position of an XML element and specifies where a difference occurred, the type of difference that occurred, and whether that difference was caused by a modification, an insertion, or a deletion.
You can determine which XPaths to ignore when running the Diff tool. You can choose to either ignore an entire XPath, or you can ignore a specific XPath operation such as a Content: Insert
operation.
Ignoring XPaths is useful for ignoring transient values that would normally cause the regression test to fail. For example, the actual outcome may contain a time stamp value that is constantly changing. Since this value is never the same, it will more than likely not match the value you configure in the Diff tool, causing the test to fail. Therefore, you can specify the XPath of this value to be ignored so that the test will not fail.
There are three different ways you can set XPaths to Ignore:
When entering XPaths to ignore in the Diff tool, it is easiest to right-click in the Quality Tasks view rather than manually entering the XPath position into the Diff tool GUI. XPath positions are displayed in tree form in the Quality Tasks view after a failed regression test:
To ignore an XPath from the Quality Tasks view after a failed regression test:
You can also manually type or paste an XPath to ignore into the Diff tool configuration panel.
To manually enter an XPath:
All XPaths added will be ignored in future runs of the modified regression test. For information on modifying ignored XPaths, see Modifying XPath Settings.
You may also ignore XPaths directly from the Form XML tree within the Form XML tab by completing the following:
Attribute (Modify/Insert/Delete): Select the attribute operation you want to ignore. If this field is selected, only the specified attribute name within the XPath will be ignored. To ignore a specific attribute, enter the attribute name in the field next to the Attribute check box. If you want to ignore more than one attribute at an element’s XPath location, leave the attribute name empty or use the wild card * (e.g. myAttribute*).
Diff tools can either have their own local, exclusive Ignored XPath settings, or they can reference a list of XPaths that can be used by other Diff tools.
By default, when you add an XPath to the Ignored Differences tab, all of the possible operations for that XPath display in the Settings column. Since all of the possible operations for the XPath are specified by default, all of these operations will be ignored the next time the regression test is run. However, you can specify which operations are ignored, rather than having all of them ignored, by modifying the XPath settings.
To modify XPath settings:
Attribute (Modify/Insert/Delete): Select the attribute operation you want to ignore. If this field is selected, only the specified attribute name within the XPath will be ignored. To ignore a specific attribute, enter the attribute name in the field next to the Attribute check box. If you want to ignore more than one attribute at an element’s XPath location, leave the attribute name empty or use the wild card * (e.g. myAttribute*).
All XPath operations specified will be ignored in future runs of the modified regression test.
In this video, you'll learn how to generate and update regression controls.