Code coverage in sapui5 OPA5 tests

左心房为你撑大大i 提交于 2020-01-03 05:53:07

问题


i can see that in SAPUI5 Qunit tests there is option for checkbox for check the code coverage (by checkbox or with an URL parameter ?coverage) But in OPA5 tests in sapui5 there isn't checkbox for code coverage and if i add the URL parameter ?coverage, the test run regular without code coverage. OPA5 test in sapui5 doesn't support code coverage?

Thanks!


回答1:


Recently Opa5 introduced component based testing, guessing from 1.34 onwards, the code for calling a component based test looks like

 iStartMyUIComponent({
   componentConfig: {
       name: <foo.my.component.path>
                },
      hash: ""
 });

prior to the component based approach, we only had the option to run the Opa5 tests via an IFrame, the code for calling a frame based test looks like

iStartMyApp: function (oOptions) {
    var sUrlParameters;
    oOptions = oOptions || { delay: 0 };

    sUrlParameters = "serverDelay=" + oOptions.delay;

    this.iStartMyAppInAFrame(getFrameUrl(oOptions.hash, sUrlParameters));
},

A lot of the older examples available use the frame approach which didn't include coverage by default, to get test coverage with the Frame approach you would use something like OpenUi5 Karma with Istanbul.

With component based OpaTests we can now get coverage via the bundled Blanket.js module

see Opa5 with Test Coverage for an example, in this example you will notice the coverage option, the checkbox is checked and there is an additional URL parameter, look down the bottom of the page for the lcov output.

To get the coverage feature in your Qunit runner you'll need to include the following module

jQuery.sap.require("sap.ui.qunit.qunit-coverage");

hth

JSP




回答2:


Add the following line of code in your opaTest.qunit.html along with other jQuery.sap.require files -

jQuery.sap.require("sap.ui.qunit.qunit-coverage");  // used for code coverage

But make sure you add it after the qunit test files and not before that.



来源:https://stackoverflow.com/questions/37782622/code-coverage-in-sapui5-opa5-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!