Diagrams

Concepts ›› Test Case Editor ››
Parent Previous Next

Diagrams

This section contains configurations for diagrams, which can be created based on information produced during test case execution, or other sources. Term diagram in this text means all types of graphical information, including graphs, charts, ...

Requirement: For sequence diagrams module seqdiag has to be installed in Python used by winIDEA. It is already present in winIDEA's internal Python, so if you have selected in winIDEA Tools | Options | Script | Internal Python x.y, then there should be no problems. If you have selected one of the other two options in this dialog to use your installation of Python, then you have to install the module seqdiag yourself. See https://pypi.python.org/pypi/seqdiag/ for installation.


Columns in the diagram configuration table have the following meaning:

Tips:

  1. To generate diagram during test case execution, check-box Is active and table column isActive must both be checked. Button Create generates a diagram regardless of these two settings.
  2. If a diagram is produced by script extension or stub/test-point script during test case execution, then add new line to table, set diagram type to custom, leave script column empty, and specify file name.
  3. If one script produces more than one file, add new line to table, set diagram type to custom, leave script column empty, and specify file name. This way it is also possible to show the same file in multiple viewers, for example internal testIDEA viewer and external viewer.
  4. When opening diagrams in multi-page editor, text on tab on the bottom of the page is taken from file name as text before extension, and after the last '-', for example: test-0-myFunc-callGraph.png ==> callGraph. To get full file name as tab name, replace all '-' in file name with some other character, for example underscore.

Built-in diagrams

testIDEA contains the following types of built-in diagrams:

Flow chart
This chart is created from static object code analysis. Test does not need to be run to get information for this diagram, but the code has to be downloaded to the target.

Call graph
This diagram shows which function has called which function, and how many times this call has been executed. It shows runtime information, which is obtained from profiler recording. Profiler has to be properly configured for this diagram (see button Auto-configure prfiler) and the test executed.

Static call graph
This diagram shows function call hierarchy. It shows static information obtained from download file, so the test does not need to be run to create this graph.

Parameters:
-t : By default functions called form the function under test are shown. If we specify this parameter, then functions which call function under test are shown.
-d <n> : By default complete hierarchy is shown. By specifying depth value, we can limit call depth shown.

Sequence diagram
This diagram shows UML sequence diagram - function calls in the same sequence as they occurred.

Directories

Files in testIDEA (analyzer output and export files, scripts, reports, images, ...) can be specified with relative or absolute paths. When relative paths are specified, the so called working directory (this is directory where relative path starts) depends on file type:

Scripts for diagrams

testIDEA already contains Python scripts for built-in diagrams. On request for drawing a diagram, the script is saved to winIDEA workspace directory.
Script files for built-in scripts always start with prefix _isys_, for example _isys_flowChart.py. Never modify these scripts, as they will be overwritten by testIDEA. Always rename them, and use them as custom scripts if you want to customize them.

Custom scripts

How to write custom scripts

To write custom scripts it is highly recommended to generate template script with button GW template or MP template. The first button generates a template script which uses graphwiz utility, the second one uses matplotlib. As comments in generated scripts suggest, use provided function for command line argument parsing. If arguments will change in future versions of testIDEA, it will not be necessary to update all custom scripts.

Description of custom script parameters

Several optional parameters and one positional are provided to custom scripts. Optional parameters are available only if the item is specified in test case.

In order to run scripts for diagrams from testIDEA and Python test script, scripts for diagrams should use the following rules:

       import sys
       import _isys_diagutils
       def main(cmdLineArgs):
           args = _isys_diagutils.parseArgs(cmdLineArgs, None)
           < ... your code ... >
       if __name__ == '__main__':
           main(sys.argv[1:])
       

See documentation in source code of template scripts for more information.

Test case with diagrams should be started at least once from testDIEA, so that built-in scripts are copied from testIDEA resources to winIDEA working directory.

Script return values

The script should return 0, if it created diagram image successfully, any other number otherwise. It is a good practice to throw an exception with informative error message in case of failure, so that user gets more information about the problem. Throwing an exception in Python automatically returns non-zero value.