In Version 6.1, Automated Unit Testing is supported by the following items:
- Three rule types – test case (Rule-AutoTest-Case), test suite (Rule-AutoTest-Suite) and flow marker (Rule-AutoTest-Case-FlowMarker).
- Automated Unit Testing landing page – A landing page with gadgets with which you can examine the application's test cases and unit test suites, schedule unit test suites, and examine the results of testing runs.
- Test suite processing – An agent activity (RunTestSuitesFromAgent) that runs unit test suites in the background.
- Email processing – A standard email account instance which sends completion emails from unit test suite runs, and the CompletedTestSuite correspondence rule used for the email message.
For information about how Automated Unit Testing works in releases before 6.1, see How Automated Unit Testing works (V5).
- Test Case Rules
- Unit Test Suite Rules
- Automated Unit Testing Landing Page
- Unit Test Suite and Email Processing
- Testing Results
- Flow Markers
You can test an individual rule on its own before testing it in the context of the entire application you are building. For certain rule types, when using Automated Unit Testing, after testing the individual rule, you can save the test data as a test case rule. Then, the next time you test that rule, you can run the test case rather than manually re-entering the test data.
Test case rules contain the clipboard and database pages that existed when the test case was created, the user input, and the results. When you run a test case, Process Commander uses the saved test data when testing the rule and then compares the results to those saved in the test case. If the results do not match, you investigate the tested rule to see what changed and determine if there is a problem.
Test case rules exist only in the context of the rule they test. You create test cases from the Test Cases tab of the rule form of the rule you are testing. For example, to create a test case for a decision table, open the decision table rule, go to the Test Cases tab, and click Record New Test Case.
Running individual test cases
You can run individual test cases manually from the Test Cases tab of the rule form of the rule you are testing. On the the Test Casestab, click the name of the test case to run it. The test case runs in the foreground using your Operator ID credentials.
To run a set of test cases at the same time, use a unit test suite.
Unit test suite rules identify:
- A set of test cases and their RuleSets
- An Operator ID used to run the test cases
You can create a unit test suite that includes all the test cases for a specific rule type or you can select individual rules and specify the sequence in which to run them.
Running unit test suites
When you run a unit test suite immediately (using the
Run Now option in the Schedule Unit Test Case window), the test cases in that unit test suite run in the foreground using your Operator ID credentials.
When you schedule a unit test suite to run at a point in time, the scheduled unit test suite runs:
- Initiated by an agent (the Pega-AutoTest agent)
- In the background (initiated by the agent)
- Using the Operator ID specified in the unit test suite rule (by default), or using the Operator ID specified in the schedule settings for that unit test suite run.
You can schedule a unit test suite to run once, or to run according to a recurrent pattern such as weekly or monthly.
In Version 6.1, the Automated Unit Testing landing page replaces the Test Manager from previous versions.
The Automated Unit Testing landing page has four gadgets:
- The Automated Unit Tests gadget shows all of the application's test cases and unit test suites. From this gadget, you can view information about a particular test case or unit test suite, including which test cases belong to a test suite and any test case saved results.
- The Dashboard gadget lists the results of your ten most recent unit test suite runs. Also, if you ran all test cases for a specific rule, those results are also listed in this gadget. You can drill down into the details of the run for each test case in the suite. If differences are found in a particular test case run, you can choose which differences to ignore in future runs.
- The Reports gadget displays the results from the last fifty (50) runs of a specific unit test suite. You can drill down into the details of the run for each test case in the suite. If differences are found in a particular test case run, you can choose which differences to ignore in future runs.
- The Schedule gadget lists all the unit test suites the user has access to and all unit test suites that are currently scheduled to run. Use this tab to schedule when to run unit test suites, and also to run a unit test suite immediately.
To see the Automated Unit Testing landing page, select > Application > Automated Unit Testing.
The activities that initiate runs of unit test suites and that send email correspondence are in an agent named Pega-AutoTest. The Pega-AutoTest agent activity named RunTestSuitesFromAgent initiates the runs for scheduled unit test suites. When you schedule a unit test suite to run at a future point in time, a schedule request is created and queued up. When the agent activity runs, it runs any unit test suite request whose scheduled time is due.
On multiple-node systems, more than one instance of the Pega-AutoTest agent is running. In this situation, Process Commander uses queue and unit test suite locking. While an agent instance is selecting a suite request from the queue, the entire queue is locked so other agents cannot select a request. After the agent selects a request, it releases the lock on the queue but it holds a lock on the unit test suite request.
When the unit test suite completes its run, the RunTestSuitesFromAgent activity uses an email correspondence rule named CompletedTestSuiteto generate an email message that contains the results of the test. The agent then uses a standard outbound email account to send this completion email to the operator who scheduled the test suite, and to any additional email addresses specified in the schedule settings for the run. The name of the standard email account is:
- Default, for Version 6.1 and Version 6.1 SP1 systems
- AutomatedUnitTesting, for Version 6.1 SP2 systems
When you run a test case, Process Commander displays the differences in the lower section of the Run Rule window.
Flow test cases do not use the Run Rule window. Differences are displayed in another way. See How to test flows with Automated Unit Testing.
Each time a unit test suite runs, Process Commander records the results from running the suite's test cases in instances of the Data-AutoTest-Result-Case class.
When a flow rule test case is included in a unit test suite, the system runs through the entire test case unless it finds a difference between the current results and those stored in the test case. If differences are found in the flow rule test case, the system stops running that test case and begins running the next test case in the unit test suite.
A flow marker allows you to jump directly to a specific point in the flow process without having to input the same information every time in order to reach that point.
To use a flow marker, go to the Test Cases tab of the flow rule, and in the Flow Markers table, select the name of the flow marker you want to jump to.
You will be brought to the step saved in the flow marker. From that step you can continue testing the flow rule normally.