1. In the Test Case Explorer, right-click the tests directory and choose Add New> Test Suite.
  2. Set the Test suite name and add a usergenerated directory in the Test suite location:

  3. Click Finish.
  4. Add a data source to the test suite:
    1. In the Test Case Explorer, right-click the ATM project, then choose Add New> Data Source.
    2. Select Table and click Finish.
    3. Enter a Name.
    4. Enable the First row specifies column names option.
    5. Double-click the fields and enter the followiing values
      • A header: password
      • A2: a1
      • A3: really_long_password
      • A4: foo
      • B header: result
      • B2: a1
      • B3: really_long_password
      • B4: goo.


    6. Save the data source file.
  5. In the Test Case Explorer, right-click TestSuite_Account_DS and choose Add New> Test Case using Wizard.
  6. Specify the test case:
    1. In the first page of the wizard, specify the File value by clicking Browse and navigating to Account.cxx. For Function, select void Account::setPassword(const char *) from the pull down menu.
    2. Click Next.
    3. Check Use data source and use the pull down menu to select the TestPasswordDS data source created earlier.
    4. For Input> Arguments> password, double-click on NULL and use the pull down menu to select {password}.



    5. Click Finish.
  7. Edit test_setPassword test case:
    1. In the Test Case Explorer, double-click the test_setPassword test case to open the test suite.
    2. Add #include "Account.hxx" to the top of the test suite.
    3. Remove the three post-condition checks at the end of the test_setPassword test case and replace with
      CPPTEST_ASSERT_CSTR_EQUAL(CPPTEST_DS_GET_CSTR("result")
      _cpptest_TestObject.getPassword());




    4. Save the changes to the test suite.

  8. Run the tests by selecting test_setPassword in the Test Case Explorer, then choosing Parasoft> Test Using> User-Defined> Run Unit Tests (Project Scope). The Test Progress Tab will report 3 tests passed and 1 assertion failures.
  9. Open the Quality Tasks view and expand Fix Unit Test Problems to review the assertion failure that we built into the Data Source table.



  10. Fix the result in the table and rerun the test to observe the correction.

You can add additional tests by simply adding or modifying rows in the data source.

  • No labels