如何使用InternIO从测试套件运行特定的测试用例

时间:2015-09-01 21:13:07

标签: testing automated-tests functional-testing intern

目前,我有一些测试套件。为了避免运行整个测试套件 - 如何从套件中运行单个测试用例。我目前的解决方法是评论我不想要的测试用例。

我的intern.js文件:

define({
 environments: [
    { browserName: 'chrome'},
  ],


  useSauceConnect: false,

  //functionalSuites: ['tests/projects/projectA/main.js'],

  tunnel: 'NullTunnel',

  excludeInstrumentation: /./
});

以下是我的main.js文件:

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



    registerSuite(function () {

        var someLib;


        return {
            setup: function () {

            },

            'TC001 - Functionality 1': function () {

            },

            'TC002 -  Functionality 2': function() {


            },

            'TC003 - Functionality 3': function() {


            },


        };
    });
});

我使用命令行运行它:要运行 - 我发出以下命令:

$ node_modules/.bin/intern-runner config=tests/intern     functionalSuites=tests/projects/projectA/main.js

有没有办法只说#34; TC001 - 功能1"和其他选定的测试用例没有评论套件中的其他测试用例?

1 个答案:

答案 0 :(得分:1)

You can use the grep command line option. The grep option specifies a regular expression that filters on test ID (test IDs that match are run), giving you a lot of flexibility when specifying which tests will run. At it's simplest, you can just provide a short string, and Intern will run any tests with IDs containing that string:

$ node_modules/.bin/intern-runner config=tests/intern  functionalSuites=tests/projects/projectA/main grep=TC001