Once these web APIs are created, they can then be called from the external system.
The following example shows a writeable web API (i.e. HTTP Method: POST) that start the test run and return the test-run ID (i.e. fv!testRunId) which can then be used by the external system to query the status and/or fetch the test results.
Writeable web APIs require you to set the HTTP Method to POST.
Assuming the writeable API listed above has been created, you would then create another web API similar to the one shown below to query the status of the test run. In this example, this web API receives a testRunId parameter (http!request.queryParameters.testRunId), and returns a text representing the status of the test run. This web API may have to be invoked more than once, until the status of the test run is COMPLETE.
Once the status returned by the previous web API is COMPLETE, you can get the entire result set by using the web API below. In this example, the test results are transformed to xml using the toxml() function so the external system can parse the test results.
If you don't want to use an external system to perform automated testing, you can alternatively use Appian forms and reports. Both have the capability of running tests and displaying the results in drillable grids and graphs.
The following example allows designers to run a test on all expression rules in an Appian system, or an application; and display the results of a test run as the test executes, or once it is finished.
The interface provides the following fields and buttons to provide the functionality described above.
Run System Test: Calls the a!startRuleTestsAll() smart service and stores the test-run ID in the local!testRunId variable, which is then displayed in the Test-run ID field.
Run App Test: Calls the - a!startRuleTestsApplications() smart service and stores the test-run ID in the local!testRunId variable, which is then displayed in the Test-run ID field.
Refresh: Calls the a!testRunStatusForId() function by passing the local!testRunId variable and saving the result in the local!testStatus variable, which is then displayed in the Status field.
This example requires you to create a new constant of type application named TEST_APPLICATIONS to run a test on select applications.
Every time the interface is re-loaded, the a!testRunResultForId() function is called to obtain test results, which can be used to update the corresponding fields and the pie chart in this interface.
The following screenshot shows what this sample SAIL interface looks like. Copy and paste an example into a new interface to see how this works.