13.4 Testing Business Rules
Before a business rule is deployed on the server, it’s best practice to perform some unit test (i.e., test the rules locally). In this section, you’ll learn how to do that with a few different methods.
Depending on the type of test scenario (e.g., functional or technical) and the specific test requirements, you can test business rules in different ways in SAP PO. Which test approach you choose also depends on whether your business rules are exposed as a web service or not. The different test options you have include the following:
-
Using the WS Navigator: http://<hostname>:<port>/wsnavigator
This is recommended for testers and non-IT users. -
Creating a test scenario from SAP NetWeaver Developer Studio in the Rule Composer DC
This isn’t recommended for nondevelopers. We’ll explain this in the next section, which discusses modeling rules with the Rules Composer. -
By testing the business rule embedded as part of a business process modeled in SAP NetWeaver Developer Studio Process Composer
When you test your business processes, you implicitly test the business rules it contains. Business rules logs and execution traces can be read using the business logs, as explained in Section 13.2.2. -
By using an external test tool
Test tools include the SoapUI or any other Simple Object Access Protocol (SOAP) client.
Using the WS Navigator or using an external test tool require that you’ve previously generated and configured an existing ruleset or flow ruleset as a web service so that it can be exposed as a web service.
How to Generate a Web Service for Business Rules
You can generate a web service for business rules in SAP PO as follows:
- From SAP NetWeaver Developer Studio, expand the Rules Composer DC containing the Rules Modeling nodes.
- Select a ruleset or flow ruleset, and right-click on it. Choose Web Service • Create WSDL Artifact from the context menu.
- A dialog box is shown in the wizard with the Service Attributes page; accept the default values, or apply changes if necessary to the suggested values. Click on Next.
- The Service Signature page is presented, the input and output types appear, and the checkboxes are selected by default. Click on Next.
- The WSDL Preview page is shown. By this point, you should be able to see the contents (WSDL parts) of the new web service.
- Click on Finish.
- Deploy the DC containing the business rules on the server.
Figure 13.22 shows the service attributes for the new ruleset web service.