Jasmine 2.0 中的测试用例是否并行运行 [英] Are test cases in Jasmine 2.0 run in parallel

查看:19
本文介绍了Jasmine 2.0 中的测试用例是否并行运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jasmine 2.0 中的测试是否并行运行?根据我的经验,它们不是文章,由 Jasmine.js: Race使用运行" 时的条件表明 Jasmine 确实并行运行它们,所以我想知道我的测试是否写错了.

Are tests in Jasmine 2.0 run in parallel? In my experience they aren't but the article , referenced by Jasmine.js: Race Conditions when using "runs" suggests that Jasmine does run them in parallel so I wondered if I was writing my tests incorrectly.

这是一组我希望在 1 秒而不是 4 秒内执行的测试.

Here is a set of tests that I would expect to execute in 1 second instead of 4 seconds.

describe("first suite", function() {
  it("first test", function(done) {
    expect(true).toBeTruthy();
    setTimeout(done, 1000);
  });

  it("second test", function(done) {
    expect(true).toBeTruthy();
    setTimeout(done, 1000);
  });
});

describe("second suite", function() {
  it("first test", function(done) {
    expect(true).toBeTruthy();
    setTimeout(done, 1000);
  });

  it("second test", function(done) {
    expect(true).toBeTruthy();
    setTimeout(done, 1000);
  });
});

我错过了什么吗?

jsFiddle

推荐答案

Jasmine 实际上并没有以任何方式并行运行您的规范.然而,可能有一些规范的异步部分花费了足够长的时间,以至于内置的时间限制已经过去,这将导致 jasmine 开始运行下一个规范,即使可能仍有代码从早期规范运行.

Jasmine does not actually run your specs in parallel in any way. It is however possible to have specs whose asynchronous portion takes long enough that the built-in time limit elapses which will cause jasmine to start running the next spec, even though there may still be code running from earlier specs.

这篇关于Jasmine 2.0 中的测试用例是否并行运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆