sapui5 OPA5 测试中的代码覆盖率 [英] Code coverage in sapui5 OPA5 tests

查看:75
本文介绍了sapui5 OPA5 测试中的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以看到,在 SAPUI5 Qunit 测试中,有一个用于检查代码覆盖率的复选框选项(通过复选框或带有 URL 参数?coverage)但是在 sapui5 中的 OPA5 测试中,没有代码覆盖率复选框,如果我添加 URL 参数?coverage,则测试将正常运行而没有代码覆盖率.sapui5 中的 OPA5 测试不支持代码覆盖率?

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?

谢谢!

推荐答案

最近Opa5引入了基于组件的测试,猜测从1.34开始,调用基于组件的测试的代码是这样的

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: ""
 });

在基于组件的方法之前,我们只能选择通过 IFrame 运行 Opa5 测试,调用基于框架的测试的代码看起来像

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));
},

许多可用的旧示例使用框架方法,默认情况下不包括覆盖率,要使用框架方法获得测试覆盖率,您可以使用 OpenUi5 Karma 和伊斯坦布尔之类的东西.

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.

使用基于组件的 OpaTests,我们现在可以通过捆绑的 Blanket.js 模块获得覆盖

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

参见 Opa5以测试覆盖率为例,在这个例子中,你会注意到覆盖率选项,复选框被选中,还有一个额外的 URL 参数,往下看页面底部的 lcov 输出.

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.

要在您的 Qunit runner 中获得覆盖功能,您需要包含以下模块

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");

JSP

这篇关于sapui5 OPA5 测试中的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆