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

How to run a specific test case from a test suite using InternIO

目前,我有几个测试套件。为了避免 运行 整个测试套件 - 我怎么能 运行 只是套件中的一个测试用例。我目前的解决方法是注释掉我不想要的测试用例。

我的 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

有没有办法 运行 只说 "TC001 - Functionality 1" 和其他选定的测试用例而不注释掉套件中的其他测试用例?

您可以使用grep command line optiongrep 选项指定一个根据测试 ID 过滤的正则表达式(匹配的测试 ID 为 运行),在指定哪些测试将 运行 时给您很大的灵活性。最简单的是,您可以只提供一个短字符串,Intern 将 运行 任何 ID 包含该字符串的测试:

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