Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space FUNCTDEV and version SVC2020.2

This topic explains how to prevent SOAtest from reporting specific suppress static analysis violations (e.g., when you generally follow a rule, but decide to ignore that rule in an isolated number of exceptional situations). Suppression schemes can be entered in the GUI or defined directly in the source code.Sections includein SOAtest. In this section:

Table of Contents
maxLevel1

About Suppressions

Suppressions are used to prevent SOAtest from reporting additional occurrences of a specific static analysis task (multiple tasks might be reported for a single rule). Suppressed messages will be sent to a special Suppressions view instead of the Quality Tasks view; this allows you to monitor those violations as needed while keeping your main results areas focused on the other errors.

You use suppressions for situations when you generally want to follow a rule, but decide to ignore that rule in an isolated number of exceptional situations. With suppressions, you can continue checking whether your code follows that rule without receiving repeated messages about your intentional rule violations. If you do not want to receive error messages for any violations of a specific rule, we recommend that you modify your Test Configurations so that they no longer check that rule.

Note that suppression settings are independent of Test Configurations. To avoid confusion, keep in mind that:

special markers that enable you to run a test or follow a code analysis rule while ignoring specific occurrences of the reported tasks. Suppressing tasks related to functional testing can reduce the amount of noise tests generate during early-stage testing or for cases when then certain steps are expected to fail. Suppressing tasks removes failures from the Quality Tasks view, but will not result in passing tests, nor will failures be removed from reports.    

Suppressions for static analysis enables you to comply with programming guidelines by defining exceptions that do not impact the critical parts of the application. Multiple tasks may be reported for a single code analysis rule, but you can apply a suppression if the rule is not applicable for a particular case. 

When you apply a suppression, a parasoft.suppress file is created in the same location as the test file. The suppression file includes information, such as which file has a suppression, the suppression author, and the reason for the suppression (see Manually Defining Suppression Files). Suppressed tasks are also removed from the Quality Tasks view. 

Suppression settings are independent of Test Configurations. The Test Configuration defines the scope of the test execution, coverage settings, and other features, as well as

...

the set of rules that are checked during static analysis.

...

 Suppressions define which

...

tasks associated with a failing test or reported by static analysis results should be visible in Quality Tasks view and reports.

...

This means that rules selected in the Test Configuration will be checked during analysis, but results that match the suppression criteria will not be displayed. 

 

Tip
titleSuppressions are message-based and not rule-based

Suppressions prevent the reporting of a specific static analysis task (e.g., fix the violation of rule X that occurs in line Y); they do not prevent the reporting of all violations of a rule. 

Defining Suppressions

To suppress a static analysis task that is shown in the Quality Tasks view:

 

Suppressing Tasks

  1. Right-click on a reported task in the Quality Tasks view and choose Suppress Task.  
    Image Added

    You can also right-click on a node containing task (rule category, specific rule, file, etc.) to suppress all children tasks.
    Image Added 

  2. Choose where you want to store your suppression(s) when prompted. Storing suppressions on Team Server is deprecated and disabled by default and will be removed in future versions. See Enabling Team Server Suppressions (Deprecated) for instructions. 
  3. Enter your reason to for suppressing the task when prompted and click OK.
    Image Added
  4. Right-click the Quality Tasks view item that represents the task you want to suppress, then choose Suppress Task from the shortcut menu.
    • To suppress all tasks in a group (a rule category, a specific rule, a file, etc.) right-click the node that represents that group, then choose Suppress All Tasks.
  5. Enter the reason for the suppression in the dialog box that opens

The task will then be " suppressed " and removed moved from the Quality Tasks view . A suppression entry will be added to the Suppressions view. If the same static analysis violation is found in subsequent tests of this project, it will be reported in the Suppressions view, but not in the Quality Tasks view.

Viewing Suppressions

To view the suppressed messages that were reported in a subsequent test run:

  • Open the Suppressions view. If this view is not available, choose Parasoft> Show View> Suppressions to open it.

The Suppression Messages view will display the following information:

  • The static analysis violation that was suppressed.
  • The reason why the task was suppressed.
  • The resource (file) to which the suppression applies.
  • The folder that contains the resource.
  • The name of the person who suppressed the task.
  • The date on which the suppression was first applied.

To sort the Suppressions view contents by one of the column headings, click that column heading.

 

Tip
titleYou can edit a suppression’s message or reason

Right-click the suppression in the Suppressions view, choose Edit Message or Edit Reason from the shortcut menu that opens, and modify the message or reason in the dialog that opens.

Using the Suppression Filter to Restrict the Suppressions Shown

You can restrict which suppressions are shown in the Suppressions view by using the available suppressions filter. 

To filter the suppressions shown in the Suppressions view:

  1. Click the Filter button in the Suppressions view toolbar. The Filters dialog will open.
  2. Check the Enabled check box to enable the filter.
  3. Use the dialog’s controls to specify your filtering criteria. Available options include:
    • Limit visible items to: Shows no more than the specified number of suppressions.
    • On any resources: Shows all suppressions for all projects.
    • On any resource in same project: Shows all suppressions for the currently-selected project.
    • On selected resource only: Shows only the suppressions entered for the currently-selected resource.
    • On selected resource only and its children: Shows only the suppressions entered for the currently-selected resource, and that resource’s children.

Clearing Suppressions

Select the suppression you want to remove and click the Red X Remove Suppression icon in the top right of the view.

to a suppression file. The file will be created in the same directory as the test file. To review the suppression, open the file in the SOAtest editor or any plain text editor. See Manually Defining Suppression Files for additional information about the content of parasoft.suppress files.

Anchor
Manually Defining Suppression Files
Manually Defining Suppression Files
Manually Defining Suppression Files

You can manually build the parasoft.suppress file by creating a text file in the same location as the test file and include suppression information in the following format:

Code Block
languagetext
suppression-begin
file: <FILE>
message: <TASK MESSAGE>
reason: <REASON FOR SUPPRESSION>
author: <SUPPRESSION AUTHOR>
suppression-end

SOAtest does not distinguish test cases by ID. All tasks from the same .tst file with the same message will suppressed. The following example shows a suppression file containing two functional test step suppressions:

Code Block
languagetext
suppression-begin
file: com.parabank.login.tests_testParabank_parasoft_com202007301253532.tst
message: The value of the property "balance" has changed from "5022.93" to "-2692".
reason: The return value does not need to be tested
author: user1
suppression-end

suppression-begin
file: com.parabank.login.tests_testParabank_parasoft_com202007301253532.tst
message: The value of the property "id" has changed from "13344" to "12345".
reason: The return value does not need to be tested
author: user1
suppression-end

Enabling Team Server Suppressions (Deprecated)

Storing suppressions on Team Server, as well as the Suppressions view, is deprecated starting with SOAtest 2020.2. You can enable Team Server suppressions and view suppressions created with an older version of SOAtest from the Suppressions (Deprecated) view:

  1. Choose Parasoft > Show View > Suppressions (deprecated) from the main menu.
  2. Choose Enable deprecated suppressions from the ellipses menu.
    Image Added 

Removing Suppressions

You can delete suppressions from the parasoft.suppress file to un-suppress a task. Re-run the test or analysis and the task will reappear in the Quality Tasks view.

If suppressions are stored on Team Server, choose a suppression and click the delete (X) button in the Suppressions (Deprecated) view. 

Image AddedIf this same static analysis violation is found in subsequent tests of this project, the task will be reported in the Quality Tasks view.