In this section:
Introduction
Unit Test Assistant can help you create parameterized test cases to test methods against different arguments. Test cases can be added with the Parameterized option available in the Unit Test Assistant view. This option allows you to add test templates for individual methods selected in the editor. The generated templates need to be manually modified and completed with parameterization data.
Creating Parameterized Tests
- Choose Parasoft> Preferences> Unit Test Assistant.
- Enable the Parameterized tests> Enable creation actions option.
- Select a method in the editor.
- Click the Parameterized action link in the Unit Test Assistant view.
- Complete the test template with parameters and modify the default UTA values.
- Run the test with Unit Test Assistant to collect coverage information and recommendations for possible improvements (see Executing Unit Tests with Unit Test Assistant).
Creating Parameterized Tests for Private Methods
UTA allows you to create parameterized tests for private methods to achieve a higher code coverage rate.
- Choose Parasoft> Preferences> Unit Test Assistant.
- Enable the Parameterized tests> Enable creation actions option.
- Enable the Test creation options> Create tests for private methods option.
- Select a private method in the editor.
- Click the Parameterized private action link to create a test for the selected method.
Cloning as a Parameterized Test
You can create a parameterized JUnit 5 test from an existing non-parameterized test from the UTA view.
Cloning an existing test as a parameterized test does not affect the original test. The existing literal values that are passed to the method under test will become test parameters. The values will be moved into a single row of data for the new test.