Setting up and cleaning the context for a test case or test suite
You can set up the environment and conditions required for running a test case, determine how to clean up test data at the end of the test run, and set pages on which to automatically run rules.
You can set clipboard pages, apply data transforms, load data pages, execute activities, create and load objects. All the referenced data pages, and data objects and user pages that were created during a test run will be automatically removed at the end of each run. To further clean up the clipboard, add steps to apply additional data transforms and execute activities. You can set up or clean up the clipboard if you are running a test for which the output or execution depends on other data pages or information.
For example, your application contains a data page D_AccountTransactionsList. This data page is sourced by a report definition or activity that loads the transactions of the logged-in customer, based on the account type for which the customer views transactions.
The customer number and account type that the customer selects are dynamic properties that are stored on the work page of the case. The report definition or activity retrieves these properties as parameters from the work page and filters the results as it obtains the results for the data page.
When you create a test case for D_AccountTransactionsList, ensure that one of the following conditions is met:
- The parameter properties are on the work page of the clipboard before running the data page test.
- Your data page has an activity or report definition that refers to the properties of another data page that is on the clipboard to filter the results.
The system always runs data transforms, activities, and strategies on the RunRecordPrimaryPage page, regardless of which page you chose when you unit tested the rule in the Run dialog box. The system also runs flows and case types on the pyWorkPage. To update the page with any information required to set up test data, click the Setup tab.
- Setting up your test environment
Configure which actions you want to run and which objects and pages you want to view on the clipboard before, during, and after the test is run.
- Cleaning up your test environment
After you run a unit test case or test suite, user and data pages used to set up the test environment and the parameter page are automatically removed by default. You can apply additional data transforms or activities to remove other pages or information on the clipboard before you run more test cases or suites.
- Converting unit tests to test cases
- Data pages
A data page defines the contents of a clipboard page and enables the system to access data from a range of sources on demand.
A keystore is a file that contains keys and certificates that you use for encryption, authentication, and serving content over HTTPS. In Pega Platform, you create a keystore data instance that points to a keystore file.
- Data Transforms
A data transform defines how to convert data that is in one format and class (the source) into data of another format and class (the target). The supported formats are clipboard and JSON. Using a data transform instead of an activity to set property values speeds up development and makes application maintenance easier.
- Unit testing an activity
You can test an activity individually before testing it in the context of the application that you are developing. Additionally, you can convert the test run to a Pega unit test case.