如果运行0测试,使黑猩猩执行失败

时间:2016-07-18 19:31:57

标签: meteor continuous-integration automated-tests chimp.js

长话短说,我有一个流星应用程序在连续集成管道中传递,该管道在部署之前运行每个测试。我的测试与黑猩猩一起运行,我在运行测试之前,在每个版本的CI环境中使用最新版本安装了chimp。

最近,黑猩猩做了一些重大更新,导致我的黑猩猩执行运行1..0测试。在发现它是因为黑猩猩的版本之后,我将黑猩猩的安装更改为本地并锁定在某个版本。

问题是我的管道传递因为嘿,0测试通过仍然是0测试失败..!

我试图让黑猩猩失败,如果它根本没有进行任何测试。怎么会这样做?

我尝试过输出输出并将其与“#1; 0..0'导致退出/ b 1状态,没有运气。最好的解决方案只涉及黑猩猩命令。

感谢任何可以给我一些暗示的人。

1 个答案:

答案 0 :(得分:0)

使用after after hook

您可以将所有测试后运行的代码放在after测试挂钩中(下面的示例)。我不确定如何查看检查运行的测试次数,但我认为你可以找到与测试记者发现它相同的方式。所以,我建议通过一个流行/更简单的记者来源比如dot / spec并从那里算出来。

describe('test', function() {
  after(function() { console.log('after'); });
  afterEach(function() { console.log('afterEach'); });

  it('fails sync', function(done) {
    after(function() { console.log('inner after 1'); });
    throw new Error('failed');
  });

  it('fails async', function(done) {
    after(function() { console.log('inner after 2'); });
    process.nextTick(function() {
      throw new Error('failed');
    });
  });
});

使用mocha 1.1.12产生以下输出:

  ․afterEach
․afterEach
after
inner after 1
inner after 2


  0 passing (5 ms)
  2 failing

1) test fails sync:
 Error: failed
  at Context.<anonymous> (/private/tmp/so/test/main.js:7:11)
  at Test.Runnable.run (/private/tmp/so/node_modules/mocha/lib/runnable.js:194:15)
  at Runner.runTest (/private/tmp/so/node_modules/mocha/lib/runner.js:355:10)
  at /private/tmp/so/node_modules/mocha/lib/runner.js:401:12
  at next (/private/tmp/so/node_modules/mocha/lib/runner.js:281:14)
  at /private/tmp/so/node_modules/mocha/lib/runner.js:290:7
  at next (/private/tmp/so/node_modules/mocha/lib/runner.js:234:23)
  at Object._onImmediate (/private/tmp/so/node_modules/mocha/lib/runner.js:258:5)
  at processImmediate [as _immediateCallback] (timers.js:330:15)

2) test fails async:
 Error: failed
  at /private/tmp/so/test/main.js:13:12
  at process._tickCallback (node.js:415:13)
  

来自SO用户MiroslavBajtoš的示例代码

相关问题