实习生2.0:在Windows上不再生成覆盖率报告(回归)

时间:2014-08-29 19:00:50

标签: code-coverage intern istanbul

使用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 +,Dom


使用配置文件进行更新:

  • 模块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插件配置进行更新:

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

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

1 个答案:

答案 0 :(得分:1)

实习生中存在导致此问题的缺陷。解决问题的补丁是https://github.com/theintern/intern/pull/255,将在Intern 2.1(可能还有2.0点发布)中登陆。