在第一次预期失败后停止茉莉花测试 [英] Stop jasmine test after first expect fails

查看:95
本文介绍了在第一次预期失败后停止茉莉花测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉python unittest测试,如果断言失败,那么测试会被标记为失败,并继续进行其他测试。另一方面,Jasmine将继续通过所有期望,即使其中一个失败。在第一次预期失败后,如何让Jasmine停止处理测试?

I'm familiar with python unittest tests where if an assertion fails, that test is marked as "failed" and it moves on to other tests. Jasmine on the other hand will continue through all expects even if the one of them fails. How can I make Jasmine stop processing a test after the first expectation fails?

it ("shouldn't need to test other expects if the first fails", function() {
    expect(array.length).toBe(1);

    // don't need to check this if the first failed.
    expect(array[0]).toBe("foo");
});

我在想错了吗?我有一些测试,有很多期望,如果只是第一个错误,显示所有堆栈跟踪似乎是浪费。

Am I thinking about it wrong? I have some tests with lots of expect's and it seems like a waste to show all the stack traces when only the first is wrong really.

推荐答案

Jasmine不支持在单个规范中提前失败。这个想法是为了解决所有的失败,以便有助于找出规范中的错误。

Jasmine doesn't support failing early, in a single spec. The idea is to give you all of the failures in case that helps figure out what is really wrong in your spec.

这篇关于在第一次预期失败后停止茉莉花测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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