Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Excluding resources from Unit Testing

brian_nuckles
brian_nuckles Posts: 32 admin
edited January 2018 in C/C++test

Some users may not want certain resources or files included in the testing scope for their unit tests. These resources can be excluded to ensure that no extraneous data is present in the tests. To indicate which project resources should not be tested during Unit Test Execution follow the steps below for your Development Environment:

Eclipse

  1. In the project tree, right-click the project that contains the files that you want excluded and select Properties.
  2. In the new window, Select Parasoft >> Scope Settings from the shortcut menu.
  3. Select the resource(s) you want to skip by clicking the "Add Resources" button.
  4. Make a copy of the built-in test configuration "Run Unit Test"
  5. In the copied "Run Unit Test" test configuration, go to the Execution Tab -> General -> Execution Details -> Instrumentation Mode and click the "Edit" button.
  6. In the new window, uncheck the Coverage check box for Additional Sources.
    User-added image
  7. Save and run the test configuration. The resource will be excluded from testing.

Visual Studio

  1. In the Solution Explorer, right-click the project that contains the files you want to excluded and select Parasoft->Properties.
    User-added image
  2. In the new window, Select Scope Settings from the shortcut menu.
  3. Select the resource(s) you want to skip by clicking the "Add Resources" button.
    User-added image
  4. Make a copy of the built-in test configuration "Run Unit Test"
  5. In the copied "Run Unit Test" test configuration, go to the Execution Tab -> General -> Execution Details -> Instrumentation Mode and click the "Edit" button.
  6. In the new window, uncheck the Coverage check box for Additional Sources. (See #Disable Coverage)
  7. Save and run the test configuration. The resource will be excluded from testing.

Comments

  • nokoru
    nokoru Posts: 19
    edited November 2021

    This seems to exclude the excluded resources as well as any resources not being tested, even if they were not added into the exclude list. Is there a way to exclude only resources added in the exclude list while including everything else?

    I am hoping to get the coverage result without a certain portion of the code that will be tested separately. I can do this easily by deleting the coverage result of the files I want to exclude from the coverage panel, but I would like to achieve the same with the generated report.

    Update: Seems like my issue was not due to the instructions provided above but rather with how I generated the results. By right clicking on the testsuites and generating the result, the scope of the result generated seems to be narrowed to the file under testing. By right clicking on the project instead and generating the result, I was able to get a report with the coverage of all the files, excluding those added to the exclude list.