无法运行样品实习生自动化测试

时间:2015-01-27 04:48:27

标签: javascript automation intern

我尝试运行简单的Intern自动化测试示例,如下所示:

define([
    'intern!object',
    'intern/chai!assert',
    'require'
], function (registerSuite, assert, require) {
    registerSuite({
        name: 'index',

        'Greeting': function () {
            return this.remote
                .get(require.toUrl('index.html'))
                .setFindTimeout(5000)
                .findByCssSelector('body.loaded')
                .findById('nameField')
                    .click()
                    .type('Elaine')
                    .end()
                .findByCssSelector('#loginForm input[type=submit]')
                    .click()
                    .end()
                .findById('greeting')
                .getVisibleText()
                .then(function (text) {
                    assert.strictEqual(text, 'Hello, ElaineqW!', 'Greeting should be displayed when the form is submitted');
                });
        }
    });
});

这应该是一件简单的事情。但是,当我尝试通过命令行运行配置时,我遇到了一个问题。

Cannot call method get null

以下是我的配置片段:

// Non-functional test suite(s) to run in each browser
    suites: [ 'C:/internKE/tests/functional/index' ],

    // Functional test suite(s) to run in each browser once non-functional tests are completed
    functionalSuites: [ 'C:/internKE/tests/functional/index' ],

我想知道我做错了什么,以便测试不会被编译。

由于

1 个答案:

答案 0 :(得分:0)

您无法将功能测试加载到单元测试系统中。请注意您粘贴的代码中的注释“非功能性”。在非功能测试中没有this.remote

另外,请注意模块ID 不是文件系统路径

您的配置应该是:

// Non-functional test suite(s) to run in each browser
suites: [],

// Functional test suite(s) to run in each browser once non-functional tests are completed
functionalSuites: [ 'tests/functional/index' ],
相关问题