docs

Integrating the Rules in OPA Tests

The Support Assistant can be used as part of an existing OPA test to cover more test aspects of the application.


The Support Assistant can be used in OPA tests to check if there are issues in the different states of the application. To do that, you need to use the Support Assistant OPA extension. This extension is available as of version 1.48. It provides three assertions:

In addition, if you pass sap-skip-rules-issues=true as a URL parameter to your OPA test, the assertion results of noRuleFailures and getFinalReport assertions will be true, overriding the actual results.

This special URL parameter could be used temporarily in cases when you extend an existing OPA test to run the Support Assistant rule checks initially but you don’t want the entire OPA journey to fail immediately. After you gain experience and clean up any check issues, you can set it to false or omit passing it and use once again the desired onError behavior.

Note:

When the sap-skip-rules-issues URL parameter is set, it affects all tests globally, unlike the FailOnAnyIssues parameters, which only affect a specific test level.


  1. Enable the Support Assistant OPA extension in the OPA configuration file.

    You need to change two parameters:

    • extensions - You need to include the Support Assistant OPA extension path (sap/ui/core/support/RuleEngineOpaExtension).

    • appParams - You need to add sap-ui-support with a value of true,silent. This will start the application in support mode and will start the Support Assistant in silent mode (without UI).

    The configuration file will look like this:

    sap.ui.define([
        "sap/ui/test/Opa5",
        ...
    ], function(Opa5, ...) {
        ...
        
        Opa5.extendConfig({
            ...
            extensions: ["sap/ui/core/support/RuleEngineOpaExtension"],
            appParams: {
                "sap-ui-support": "true,silent"
            }
        });
    });
        
    
  2. Add additional assertions to the OPA configuration file.

    Add generic or specific assertions - depending on the use case. For example:

    • iShouldSeeNoHighSeverityErrors - This assertion calls noRuleFailures with a few parameters set, as you can see in the example code below. It checks for high issues and ignores medium and low. The rules checked are preloadAsyncCheck, orphanedElement, deprecatedEntities and the scope is set to global.

    • iShouldGetSupportRuleReport- This assertion calls getFinalReport and if there are any issues after all the analysis, it fails and a report is created as part of the message.

    The configuration file should look like this:

    assertions: new Opa5({
    ...
    iShouldSeeNoHighSeverityErrors: function() {
      return this.waitFor({
        success: function() {
          Opa5.assert.noRuleFailures({
            "failOnHighIssues": true,
            rules: [{
              libName: "sap.ui.core",
              ruleId: "preloadAsyncCheck"
            }, {
              libName: "sap.ui.core",
              ruleId: "orphanedElement"
            }, {
              libName: "sap.ui.core",
              ruleId: "deprecatedEntities"
            }],
            executionScope: {
              type: "global"
            }
          });
        }
      });
    },
    iShouldGetSupportRuleReport: function() {
      return this.waitFor({
        success: function() {
          Opa5.assert.getFinalReport();
        }
      });
    }
    ...
        
    
  3. The added assertions can now be used inside the journeys.

    Knowing the flow of the tests, choose the right place in your OPA test journey to add the needed assertion:

    ...
    opaTest("Should see no Support Assistant issues with high severity", function (Given, When, Then) {
    	Then.iShouldSeeNoHighSeverityErrors();
    });
    ...
        
    

    Note:

    Put these assertions after the web page being tested has been rendered and displayed with a stable UI.

  4. Repeat the extended OPA test and see how your specific Support Assistant assertions are triggered.

    You can see a detailed report for each run. The report is tabular and lists all executed rules with their details, followed by a list of the issues generated by that rule. It looks like this:

    OPA Test Results

Related Information

Execution Scope

Integration Testing with One Page Acceptance Tests (OPA5)

Samples: Running OPA tests with Support Assistant checks