This lesson explains how to create and make assertions for multiple test cases for one or more methods.
Exercise 1 - Creating Tests for Multiple Methods in a Class
- In your IDE, choose Parasoft> Preferences> Unit Test Assistant in the menu bar.
- Disable the Generate sample assertions option and click OK.
- Open the jtest-examples> src/main/java> examples.junit> MoneyBag class in the editor and click anywhere in the class.
- Choose the Add test case(s) action in the UTA interface.
- Select all the listed methods in the dialog that opens and click OK. UTA will create a test class MoneyBagTest.java that includes tests for all the selected methods.
- Open the MoneyBagTest.java class in the editor and click anywhere in the class.
- Choose the Track and make assertions action in the UTA interface. UTA will run all the tests from the MoneBagTest class and update the test code with the recommended assertions.
When the run is completed, UTA displays the number of updated tests and the total number of the assertions that were added during the run. The tests that fail are not updated.
- Open the MoneyBagTest.java file to verify that the assertions were added.
Exercise 2 - Creating Tests for Multiple Methods in a Package
When the run is completed, UTA displays the number of updated test classes and test cases, as well as the total number of the assertions that were added during the run. The tests that fail are not updated.
Open jtest-examples> src/main/java> examples.mock> MultiSourceCharacterReader.java to verify that the assertions were added.