【问题标题】:Intern 2.0: coverage report not generated anymore on Windows (regression)实习生 2.0:不再在 Windows 上生成覆盖率报告(回归)
【发布时间】:2014-08-29 19:00:50
【问题描述】:

使用 Intern 版本 1.7,我能够在 Windows (Git Bash) 和 CentOS(在 VirtualBox VM 内)上运行 node node_modules/intern/bin/intern-client.js config=test/internNode。如果至少有一项测试失败,则不会生成覆盖率报告。

在 Intern 2.0 版中,覆盖率报告永远不会在 Windows 上生成,只能在 CentOS 上生成。如果测试失败,它们现在甚至会生成...

似乎任何 Intern 依赖项都不依赖于平台。是否有可能由于刚刚为 Linux 格式化的路径而出现故障?

A+,多姆


更新配置文件:

  • 模块FileScanner 检索指定文件夹中与给定正则表达式匹配的所有文件。它避免了记录要运行的测试文件的静态列表。
  • 测试套件运行代码来验证客户端逻辑和服务器逻辑。

.

/*global define*/
define([
    'intern/node_modules/dojo/has',
    'src/tests/FileScanner'
], function (has, FileScanner) {
    'use strict';

    has.add('tests-api', true); // To enable entry points for test purposes
    has.add('dojo-debug-messages', false); //

    var unitTestFiles = new FileScanner.getFiles(['src/client/ubi', 'src/server'], /(?:\w+\/)*\w+Test\.js$/),
        functionTestFiles = [];

    return {
        useLoader: {
            'host-node': 'dojo/dojo'
        },

        loader: {
            map: {
                '*': {
                    'dojo/has': 'intern/node_modules/dojo/has',
                    'dojo/node': 'intern/node_modules/dojo/node',
                    'dojo/text': 'ubi/utils/tests/dojo/textMock',
                    'dojo/parser': 'ubi/utils/tests/dojo/parserMock',
                    'dijit/_TemplatedMixin': 'ubi/utils/tests/dijit/_TemplatedMixinMock',
                    'dijit/_WidgetBase': 'ubi/utils/tests/dijit/_WidgetBaseMock',
                    'dijit/_WidgetsInTemplateMixin':  'ubi/utils/tests/dijit/_WidgetsInTemplateMixinMock',
                    'dijit/_AttachMixin': 'ubi/utils/tests/dijit/_AttachMixinMock',

                    // To limit side-effects of the GFX library
                    'dojox/charting/Chart': 'ubi/utils/tests/noopMock',
                    'dojox/charting/widget/Chart': 'ubi/utils/tests/noopMock',
                    'dojox/charting/axis2d/Default': 'ubi/utils/tests/noopMock',
                    'dojox/charting/plot2d/Lines': 'ubi/utils/tests/noopMock',
                    'dojox/charting/plot2d/Markers': 'ubi/utils/tests/noopMock',
                    'dojox/charting/plot2d/Pie': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/Highlight': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/Magnify': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/MoveSlice': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/PlotAction': 'ubi/utils/tests/noopMock',
                    'ubi/charting/themes/omega': 'ubi/utils/tests/noopMock'
                }
            },
            packages: [{
                name: 'dojo',
                location: 'src/libs/dojo'
            }, {
                name: 'dijit',
                location: 'src/libs/dijit'
            }, {
                name: 'dojox',
                location: 'src/libs/dojox'
            }, {
                name: 'ubi',
                location: 'src/client/ubi'
            }, {
                name: 'server',
                location: 'src/server'
            }, {
                name: 'tests',
                location: 'src/tests'
            }]
        },

        suites: unitTestFiles,

        functionalSuites: functionTestFiles,

        excludeInstrumentation: /(?:node_modules|libs|tests)/
    };
});

更新 Gruntfile 插件配置:

  • unitTest 变量使用作为参数提供给 grunt 命令的值获取
  • 我用它一次运行一个测试套件

.

intern: {
    'unit-tests': {
        options: {
            runType: 'client',
            config: 'src/tests/internNode',
            reporters: ['console', 'lcovhtml'],
            reportDir: 'target/code-coverage',
            suites: unitTest === null ? [] : [unitTest]
        }
    }
}

【问题讨论】:

  • 请注意,从 Intern 配置中删除 excludeInstrumentation 属性可以生成报告。我在stackoverflow.com/questions/23290853/… 中发现了这个技巧
  • 您至少需要提供您的配置,以便任何人都能够回答您的问题。
  • 由于我在升级过程中没有更改配置文件,我认为它不相关......但是,我将使用该信息更新问题。
  • 谢谢。在挖掘之前验证excludeInstrumentation 的外观非常重要。

标签: code-coverage intern istanbul


【解决方案1】:

Intern 中存在导致此问题的缺陷。解决该问题的补丁程序位于 https://github.com/theintern/intern/pull/255,并将登陆 Intern 2.1(可能还有另一个 2.0 点版本)。

【讨论】:

  • 感谢科林的更新。我希望对 Intern issue #71 的修复也能使其成为 2.1。
  • 仅供参考,我刚刚更新了我的本地 runner.js 副本以规范化 basePath 并且它不能纠正问题,因为我的测试是由 client.js 运行的,而不是 runner.js。请参阅上面的 Gruntfile 配置;)
  • 是的,lib/realClient.js 中存在相同的行,所以它在那里也行不通。
  • 你说得对:在生成的 basePath 第 78 行调用 path.normalize() 可以修复该行为。感谢您确定要修复的正确文件;)
猜你喜欢
  • 2013-12-04
  • 2018-09-09
  • 1970-01-01
  • 1970-01-01
  • 2022-06-15
  • 2021-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多