0

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

在 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]
        }
    }
}
4

1 回答 1

1

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

于 2014-09-02T18:40:13.947 回答